Index: /trunk/MagicSoft/Mars/Changelog
===================================================================
--- /trunk/MagicSoft/Mars/Changelog	(revision 9283)
+++ /trunk/MagicSoft/Mars/Changelog	(revision 9284)
@@ -19,4 +19,14 @@
                                                  -*-*- END OF LINE -*-*-
 
+ 2009/01/30 Thomas Bretz
+
+   * datacenter/macros/fillcmt.C:
+     - added
+
+   * datacenter/macros/plotstat.C:
+     - extended loop to show all periods again
+
+
+
  2009/01/29 Thomas Bretz
 
@@ -32,4 +42,7 @@
    * datacenter/macros/plotdb.C:
      - updated comments
+
+   * resources/calibration_spline.rc:
+     - updated
 
 
@@ -285,424 +298,3 @@
      msimreflector/MMirrorHex.cc, msimreflector/MMirrorSquare.[h,cc],
      msimreflector/MReflector.cc, msimreflector/MSimReflector.cc,
-     melectronics/MAnalogSignal.cc:
-     - moved code which needs TMath to source file
-     - included TMath for newer root versions
-     - included TObjArray for newer root versions
-
-   * msimcamera/MSimAPD.[h,cc], msimcamera/MSimBundlePhotons.[h,cc], 
-     msimcamera/MSimRandomPhotons.[h,cc]:
-     - added
-
-   * melectronics/Makefile, melectronics/MAnalogChannels.[h,cc],
-     melectronics/ElectronicsIncl.h, melectronics/ElectronicsLinkDef.h, 
-     melectronics/MDigitalSignal.[h,cc],  
-     melectronics/MAnalogSignal.[h,cc], 
-     melectronics/MAvalanchePhotoDiode.[h,cc]:
-     - added
-
-   * msim/M*.cc, msimreflector/M*.cc, msimcamera/M*.cc:
-     - changed copyright notice
-
-   * mjobs/MJob.[h,cc]:
-     - for convinience replaced GetEnvValue by GetEnvValue2
-     - added initialization of the random number generator
-
-   * ceres.cc, mcorsika/CorsikaIncl.h:
-     - added
-
-
-
- 2009/01/22 Thomas Bretz
-
-   * mraw/MRawRunHeader.h:
-     - added new functions to access the runtype
-
-   * msim/MPhotonData.cc:
-     - removed some obsolete comments
-
-   * msim/MPhotonEvent.[h,cc]
-     - added some comments
-     - added new member function GetFirst and GetLast
-     - UnSort the array after reading new data
-     - removed some old obsolete code
-     - added new meber function Sort and IsSorted
-
-   * msimreflector/MSimReflector.cc:
-     - force sorting of the array
-
-  * msimcamera/MSimPSF.[h,cc], msimcamera/MSimGeomCam.[h,cc], 
-    msimcamera/MSimExcessNoise.[h,cc], msimcamera/MSimSignalCam.[h,cc]:
-    - added
-
-
-
- 2009/01/21 Thomas Bretz
-
-   * mbase/BaseLinkDef.h, mbase/Makefile:
-     - added MQuaternion
-     - added MReflection
-
-   * mbase/MQuaternion.[h,cc], mbase/MReflection.[h,cc]:
-     - added
-
-   * mbase/MArrayI.[h,cc]:
-     - added a few new functions (ReSort, Add, Find and AddUniq)
-
-   * mbase/MMath.cc:
-     - replaced delete by delete[] where appropriate
-
-   * mgeom/MGeomCam.h:
-     - added new virtual functions HitFrame and HitDetector
-     - included MQuaternion
-
-   * mgeom/MGeomCamDwarf.[h,cc], mgeom/MGeomCamMagic.[h,cc]:
-     - added new functions HitFrame and HitDetector:
-
-   * msim/MHPhotonEvent.cc:
-     - removed the reference to MCamera
-
-   * mgeom/MGeomPix.[h,cc], mgui/MHexagon.[h,cc]:
-     - moved DistanceToPrimitive from MHexagon to MGeomPix
-     - moved the funtions to calculate overlapping areas 
-       also, but they are still in a comment
-
-   * mgui/MHexagon.[h,cc]:
-     - started implementing a rotation angle
-     - added data meber fPhi
-     - increased class version number
-
-   * mhist/MHCamera.cc, mtools/MagicJam.cc:
-     - we don't have to use a MHexagon anymore caluclating 
-       DistanceToPrimitive
-
-   * msimreflector/MMirror.[h,cc], msimreflector/MMirrorSquare.[h,cc],
-     msimreflector/MMirrorHex.[h,cc], msimreflector/MMirrorDisk.[h,cc],
-     msimreflector/MReflector.[h,cc], msimreflector/MSimReflector.[h,cc],
-     msimreflector/Makefile, msimreflector/SimReflectorLinkDef.h, 
-     msimreflector/SimReflectorIncl.h:
-     - added
-
-
-
- 2009/01/21 Stefan Ruegamer
-
-   * datacenter/scripts/read_lapalma-tapes:
-     - added check of the tape slot when exporting the tapes
-
-
-
- 2009/01/20 Thomas Bretz
-
-   * mjobs/MJob.h:
-     - added Esc member function
-
-   * msim/MPhotonData.[h,cc], msim/MPhotonEvent.[h,cc], 
-     msim/MSimAbsorption.[h,cc], msim/MSimPointingPos.[h,cc],
-     MHPhotonEvent.[h,cc], msim/Makefile, msim/SimIncl.h 
-     msim/SimLinkDef.h:
-     - added
-
-
- 2009/01/19 Thomas Bretz
-
-   * mfileio/MWriteRootFile.cc:
-     - simplified how the rules are evaluated using TPregexp
-     - by this the rules got more powerful
-
-   * mjobs/MJCalibrateSignal.cc, mjobs/MJStar.cc:
-     - changed ols style rule to new style
-
-
-
- 2009/01/18 Thomas Bretz
-
-   * mbase/BaseLinkDef.h, mbase/Makefile:
-     - added MSpline3
-
-   * mcorsika/MCorsikaEvtHeader.cc:
-     - some little cosmetics
-
-   * mcorsika/MCorsikaEvtHeader.h:
-     - added some missing getters
-
-   * mcorsika/MCorsikaRunHeader.cc:
-     - removed some obsolete comments
-     - reordered some comments
-
-   * mextralgo/MExtralgoSpline.h:
-     - changed default in GetIntegral from true to false
-
-   * mraw/MRawEvtHeader.h:
-     - added Setter for DAQEventNumber
-
-   * mraw/MRawRunHeader.cc:
-     - start pixel hardware indices with 1 not with 0
-
-
-
- 2009/01/17 Thomas Bretz
-
-  * mbase/MMath.[h,cc]:
-     - added a new function RndmExp which should be a tiny bit faster than
-       root's own implementation because it ises Rndm() instead of Uniform()
-
-   * mextralgo/ExtralgoIncl.h:
-     - added MArrayF
-
-   * mextralgo/MExtralgoSpline.[h,cc]:
-     - divided FindY into FindYup and FindYdn to avoid an obsolete if-clause
-     - added a new member function to return the integral function of the
-       spline. This is useful to init a new spline and use it for 
-       producing the proper random distribution.
-
-   * mpedestal/MPedestalSubtractedEvt.[h,cc]:
-     - added Print() function
-
-   * mraw/MRawEvtData.[h,cc]:
-     - added a member function to Reset the arrays
-     - added member function to set the pixel indices
-     - Improved the new Set function
-
-  * readcorsika.cc:
-    - added
-
-
-
- 2009/01/16 Daniel Hoehne-Moench
-
-   * datacenter/scripts/mcsequences:
-     - implemented sumtrigger -> modes, fTriggerFlagKEY
-     - fPriority(MCSequenceProcessStatus) is now filled into the mcdb
-
-   * datacenter/scripts/fillmccallisto, fillmcstar:
-     - bugfix: changed argument of $primaries from [$s+$s] to [$s]
-
-   * datacenter/macros/fillcamera.C:
-     - changed NumPheFromDNSB to float(7,3)
-     - fPriority(MCRunProcessStatus) is now filled into the mcdb
-
-   * datacenter/macros/fillmccalib.C:
-     - minor changes, bugfix (wrong column name for mcdb)
-
-   * datacenter/macros/fillmcsignal.C:
-     - definition of some parameters changed according to fillsignal.C
-     - minor changes, deleted unnecessary code
-     - implemented if clause for HiLo-Parameters. Instead of 
-       seqno<200000 the fAmplFadcKEY is queried in the mcdb for each
-       sequence. For MUX MCs the HiLo-Parameters are not calculated.
-
-
-
- 2009/01/15 Thomas Bretz
-
-   * callisto.cc:
-     - cosmetics to output
-
-   * mcorsika/MCorsikaRunHeader.cc:
-     - cosmetics (removed a ;;)
-
-   * mhist/MHEvent.[h,cc]:
-     - ReInit to allow the change of the camera geoemtry in ReInit
-
-
-
- 2009/01/15 Stefan Ruegamer
-
-   * datacenter/scripts/dodatacheck:
-     - removed the _E in the find command; files from 2008/06/04 on do
-       not have it any more
-
-
-
- 2009/01/14 Daniel Hoehne-Moench
-
-   * datacenter/scripts/sourcefile:
-     - extended errorcoding on mc run process status
-
-   * datacenter/scripts/runmccallisto, runmcstar:
-     - deleted unnecessary lines, adapted to primary structure
-
-   * datacenter/macros/fillmcsignal.C, fillmccalib.C, fillmcstar.C:
-     - added
-
-   * datacenter/scripts/fillmccallisto, fillmcstar:
-     - added
-
-
-
- 2009/01/14 Thomas Bretz
-
-   * readraw.cc:
-     - check first whether the file exist before adding the extension
-
-   * mbase/MMath.[h,cc]:
-     - added function to Re-sort an array
-
-   * mfileio/MReadMarsFile.cc, mfileio/MWriteRootFile.cc:
-     - Improved output
-
-   * mfileio/MWriteRootFile.cc:
-     - fixed a problem which prevented to open more than one /dev/null
-       devices independantly
-
-   * mgeom/MGeomCam.cc:
-     - cosmetics
-
-   * mgeom/MGeomCamDwarf.h:
-     - fixed a typo in an ifdef
-
-   * mgeom/MGeomPix.[h,cc]:
-     - added funtion to return positon as TVector2
-     - slightly improved the algorithm to check IsInside
-     - fixed the conditional signs for the orientation of pixels
-       in GetDirection
-
-   * mmain/MEventDisplay.cc:
-     - Give different names to the MPedestalSubtract tasks
-     - fixed buttons
-     - call AddGeometryTags after ReInit to allow reading new geometries in
-       ReInit
-
-   * mmc/MMcEvtBasic.h:
-     - added a new primary type kNightSky
-
-   * mraw/MRawEvtPixelIter.h:
-     - replaced type of the number of bytes by UInt_t
-
-   * mraw/MRawRunHeader.h:
-     - allow to validate the magic-number from outside (for MCs)
-
-   * datacenter/scripts/runcorsika:
-     - added a lot of comments
-     - reordered values in input card
-     - switched off a lot of obsolete output
-     - changed the Magnetic field to a value corresponding to the location of
-       MAGIC at 2200m height valid for January 2009. (The old value never took
-       place there?!) The value was taken from www.noaa.gov/geomagmodels
-
-
-
- 2009/01/12 Daniel Hoehne-Moench
-
-   * datacenter/db/menu.php:
-     - bugfix: now the SumTriggerFlag is correctly displayed in the web
-       interface
-
-
-
- 2009/01/09 Daniel Hoehne-Moench
-
-   * datacenter/macros/fillcamera.C
-     - implemented new variables: zbinmin, zbinmax, number of 
-       sumtriggers, sum trigger flag
-     - bugfix: for P and C runs the mirror fraction and the impact
-       parameter had unreasonable values (negative) which were filled
-       into the mcdb, now->0
-
-   * datacenter/scripts/fillcamera, mcsequences:
-     - implemented call of getdbsetup
-
-
-
- 2009/01/09 Stefan Ruegamer
-
-   * datacenter/scripts/buildsequenceentries
-     - corrected IFS argument
-
-
-
- 2009/01/08 Stefan Ruegamer
-
-   * datacenter/scripts/filesondisk
-     - added S and N runs
-
-
-
- 2009/01/07 Daniel Hoehne-Moench
-
-   * datacenter/macros/filldotrun.C:
-     - updated column counting numbers
-     - included a check for the number of columns in the runfiles
-   
-   * datacenter/macros/buildsequenceentries.C:
-     - implemented SumTriggerFlagKEY for sequence building
-
-
-
- 2009/01/06 Thomas Bretz
-
-   * mbase/MArrayB.h, mbase/MArrayD.h, mbase/MArrayF.h,
-     mbase/MArrayI.h, mbase/MArrayS.h:
-     - removed GetSize
-
-   * mbase/MArrayF.h:
-     - added Add()
-     - added AddClipped
-
-  * mbase/MMath.[h,cc]:
-     - implemented ReSort
-
-   * mcorsika/MCorsikaEvtHeader.cc:
-     - removed obsolete comments
-
-   * mcorsika/MCorsikaRead.cc:
-     - cosmetics
-
-   * mcorsika/MCorsikaRunHeader.[h,cc]:
-     - added comments about file contents
-     - added fWavelengthMin/Max
-
-   * mextralgo/MExtralgoSpline.[h,cc]:
-     - renamed SearchY to SearchYdn
-     - fixed a problem in SearchYup (must be ++i instead of i++)
-       (this is relatively unimportant because it was only used
-        in the determination of the pulse width which we never
-        really used)
-     - added a sanity/range-check to SearchYup and SearchYdn
-     - added a comment
-     - changed the order of arguments in EvalDeriv1
-     - changed the order of arguments in EvalDeriv2
-     - accelerated EvalDeriv1 (one multiplication less)
-     - added Deriv1 function 
-     - made SearchYup and SearchYdn public
-
-   * mjobs/MDataSet.cc:
-     - removed an obsolete return statement
-
-   * mraw/MRawEvtData.[h,cc]:
-     - changed pointer in AddPixel to reference
-     - added a Set function
-
-   * mraw/MRawRunHeader.[h,cc]:
-     - added a lot of fixes for wrong run numbers written by Arehucas
-     - added a fix for strange file numbers written by Arehucas
-     - added functions as monta carlo interface to set contents
-
-   * msignal/MSignalCam.cc:
-     - defined a case 9
-
-
-
- 2009/01/05 Thomas Bretz
-
-   * mhbase/MH.h:
-     - commited missing changes from last year
-
-   * merpp.cc:
-     - fixed a description
-
-   * sponde.cc:
-     - added "Multiple dataset at once"
-
-   * star.cc:
-     - removed obsolete -ff option from output
-
-   * mbase/MTime.[h,cc]:
-     - added GetBinary
-     - added WriteBinary
-
-   * mbase/MEvtLoop.cc:
-     - display paused status in status line
-     - improved pause handling
-
-
+ 
Index: /trunk/MagicSoft/Mars/datacenter/macros/fillcmt.C
===================================================================
--- /trunk/MagicSoft/Mars/datacenter/macros/fillcmt.C	(revision 9284)
+++ /trunk/MagicSoft/Mars/datacenter/macros/fillcmt.C	(revision 9284)
@@ -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, 01/2009 <mailto:tbretz@astro.uni-wuerzburg.de>
+!
+!   Copyright: MAGIC Software Development, 2000-2009
+!
+!
+\* ======================================================================== */
+
+/////////////////////////////////////////////////////////////////////////////
+//
+// fillcmt.C
+// =========
+//
+// This macro is used to read an extinction file from the CMT and fill
+// its contents into the db.
+//
+// Usage:
+//   .x fillcmt.C("camext.06", kTRUE)
+//
+// The second argument is the 'dummy-mode'. If it is kTRUE dummy-mode is
+// switched on and nothing will be written into the database. This is usefull
+// for tests.
+//
+// Filling the database is done with 'UPADTE' for _all_ columns
+// matching the date!
+//
+// 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 fillcmt.C+\(\"filename\"\,kFALSE\) 2>&1 | tee fillcmt.log
+//
+// Make sure, that database and password are corretly set in a resource
+// file called sql.rc and the resource file is found.
+//
+// Returns 2 in case of failure, 1 in case of success and 0 if the connection
+// to the database is not working.
+//
+/////////////////////////////////////////////////////////////////////////////
+
+#include <fstream>
+#include <iostream>
+#include <errno.h>
+
+#include <TEnv.h>
+#include <TSystem.h>
+
+#include "MLog.h"
+#include "MLogManip.h"
+
+#include "MTime.h"
+#include "MSQLMagic.h"
+
+using namespace std;
+
+int fillcmt(TString fname, Bool_t dummy=kTRUE)
+{
+    TEnv env("sql.rc");
+
+    MSQLMagic serv(env);
+    if (!serv.IsConnected())
+    {
+        cout << "ERROR - Connection to database failed." << endl;
+        return 0;
+    }
+
+    serv.SetIsDummy(dummy);
+
+    gSystem->ExpandPathName(fname);
+
+    cout << "fillcmt" << endl;
+    cout << "-------" << endl;
+    cout << endl;
+    cout << "Connected to " << serv.GetName() << endl;
+    cout << "File: " << fname << endl;
+    cout << endl;
+
+
+    ifstream fin(fname);
+    if (!fin)
+    {
+        gLog << err << "Cannot open file " << fname << ": ";
+        gLog << strerror(errno) << endl;
+        return 2;
+    }
+
+    TString line;
+    for (int i=0; i<23; i++)
+        line.ReadLine(fin);
+
+    if (!fin)
+    {
+        gLog << err << "File " << fname << ": Not enough lines." << endl;
+        return 2;
+    }
+
+    while (1)
+    {
+        line.ReadLine(fin);
+        if (!fin)
+            break;
+
+        const_cast<char&>(line.Data()[ 6]) = 0;
+        const_cast<char&>(line.Data()[10]) = 0;
+        const_cast<char&>(line.Data()[19]) = 0;
+        const_cast<char&>(line.Data()[35]) = 0;
+        const_cast<char&>(line.Data()[39]) = 0;
+        const_cast<char&>(line.Data()[45]) = 0;
+        const_cast<char&>(line.Data()[51]) = 0;
+
+        const Int_t checked = atoi(line.Data()+7);
+        if (checked==0)
+            continue;
+
+        const TString date    = line.Data();
+        const Float_t extr    = atof(line.Data()+11);     //5.3
+        const Int_t   phot    = line.Data()[18] == ':';
+        const Float_t extrerr = atof(line.Data()+20);     //5.3
+        const Float_t tmphot  = atof(line.Data()+40);     //5.2
+        const Float_t tmnphot = atof(line.Data()+46);     //5.2
+
+        MTime t;
+        t.SetStringFmt(date, "%y%m%d");
+
+        const TString vars = Form("fExtinctionR=%.3f, "
+                                  "fExtinctionRerr=%.3f, "
+                                  "fIsPhotometric=%d, "
+                                  "fTimePhotometric=%.2f, "
+                                  "fTimeNonPhotometric=%.2f",
+                                  extr, extrerr, phot, tmphot, tmnphot);
+
+
+        const TString where = Form("fData='%s'", t.GetSqlDateTime().Data());
+
+        if (!serv.InsertUpdate("ExtinctionCMT", vars, where))
+            return 2;
+    }
+
+    return 1;
+}
Index: /trunk/MagicSoft/Mars/datacenter/macros/plotstat.C
===================================================================
--- /trunk/MagicSoft/Mars/datacenter/macros/plotstat.C	(revision 9283)
+++ /trunk/MagicSoft/Mars/datacenter/macros/plotstat.C	(revision 9284)
@@ -1,4 +1,4 @@
 /* ======================================================================== *\
-! $Name: not supported by cvs2svn $:$Id: plotstat.C,v 1.10 2008-11-12 13:38:17 tbretz Exp $
+! $Name: not supported by cvs2svn $:$Id: plotstat.C,v 1.11 2009-01-30 14:58:40 tbretz Exp $
 ! --------------------------------------------------------------------------
 !
@@ -556,5 +556,5 @@
     TObject *leg=DrawLegend(h);
 
-    for (int i=h[0].GetNbinsX()-1; i>=40; i--)
+    for (int i=h[0].GetNbinsX()-1; i>=0; i--)
     {
         const Int_t num = TMath::Nint(h[0].GetBinCenter(i+1));
