Changeset 7432


Ignore:
Timestamp:
11/28/05 11:15:09 (19 years ago)
Author:
tbretz
Message:
*** empty log message ***
Location:
trunk/MagicSoft/Mars
Files:
19 edited

Legend:

Unmodified
Added
Removed
  • trunk/MagicSoft/Mars/Changelog

    r7431 r7432  
    1818
    1919                                                 -*-*- END OF LINE -*-*-
     20 2005/11/28 Thomas Bretz
     21
     22   * callisto.cc, ganymed.cc, mars.cc, merpp.cc, readdaq.cc,
     23     readraw.cc, showlog.cc, showplot.cc, sponde.cc, star.cc:
     24     - fixed a bug in displaying the startup message which prevented
     25       the compilation date from beeing displayed
     26     - added abbreviations for calling some programs (see NEWS)
     27
     28   * mastro/MAstro.[h,cc]:
     29     - added function to calc date of easter
     30
     31   * mbase/MEnv.[h,cc]:
     32     - added function to support some attributes (TAtt*)
     33
     34   * mbase/MTime.[h,cc]:
     35     - added support for locales in Set/GetStringFmt
     36     - added function to calc date of easter
     37
     38   * mjobs/MJCut.cc:
     39     - output is called "Hadronness" not "MHadronness"
     40
     41
     42
    2043 2005/11/25 Thomas Bretz
    2144
  • trunk/MagicSoft/Mars/NEWS

    r7431 r7432  
    22
    33 *** Version  <cvs>
     4
     5   - general: Fixed a bug in most of the programs which prevented the
     6     compile date in the startup message to be displayed
     7
     8   - general: Simplified program calls. The following abbreviations
     9     are now possible:
     10        showlog callisto 55599
     11        showplot signal 55599
     12        star 55599
     13        callisto 55999
     14        ganymed 2
     15     In this cases the corrsponding root-, log-, sequence- or dataset-
     16     filename is automatically compiled using the default datacenter
     17     paths ("/magic/*")
    418
    519   - general: Fixed a long outstanding bug which made axis tick marks
     
    1832     is useful to perform g/h-separation cuts before training the random
    1933     forest.
     34
     35   - StatusDisplay: Fixed the algorithm to calculate the size ratio
     36     of the display, it gave wrong results espacially for big sizes.
     37     Now the embedded canvas should always have a ratio width/height=3/2.
     38     The "Size" options have been updated with values fitting the 3/2
     39     size ratio.
    2040
    2141   - RanForest:
  • trunk/MagicSoft/Mars/callisto.cc

    r7349 r7432  
    3333    gLog << "                 Callisto - MARS V" << MARSVER            << endl;
    3434    gLog << "    MARS -- CALibrate LIght Signals and Time Offsets"     << endl;
    35     gLog << "   Compiled with ROOT v" << ROOTVER << " on <" << __DATE__ ">" << endl;
     35    gLog << "   Compiled with ROOT v" << ROOTVER << " on <" << __DATE__ << ">" << endl;
    3636    gLog << "========================================================" << endl;
    3737    gLog << endl;
     
    4444    gLog << all << endl;
    4545    gLog << "Sorry the usage is:" << endl;
    46     gLog << " callisto [-c] [-y] [options] sequence.txt" << endl << endl;
     46    gLog << " callisto [-c] [-y] [options] sequence.txt|number" << endl << endl;
    4747    gLog << " Arguments:" << endl;
    4848    gLog << "   sequence.txt:             ASCII file defining a sequence of runs" << endl;
     49    gLog << "   number:                   The sequence number (using file in the datacenter)" << endl;
    4950    gLog << "                             For more details see MSequence" << endl;
    5051    gLog << " Root Options:" << endl;
     
    248249    // Setup sequence file and check for its existance
    249250    //
    250     const TString kSequence = arg.GetArgumentStr(0);
     251    TString kSequence = arg.GetArgumentStr(0);
     252
     253    if (kSequence.IsDigit())
     254    {
     255        const Int_t numseq = kSequence.Atoi();
     256        kSequence = Form("/magic/sequences/%04d/sequence%08d.txt", numseq/10000, numseq);
     257        gLog << inf << "Inflated sequence file: " << kSequence << endl;
     258    }
    251259
    252260    if (gSystem->AccessPathName(kSequence, kFileExists))
  • trunk/MagicSoft/Mars/ganymed.cc

    r7409 r7432  
    3030    gLog << "                  Ganymed - MARS V" << MARSVER            << endl;
    3131    gLog << "   MARS -- Gammas Are Now Your Most Exciting Discovery"   << endl;
    32     gLog << "   Compiled with ROOT v" << ROOTVER << " on <" << __DATE__ ">" << endl;
     32    gLog << "   Compiled with ROOT v" << ROOTVER << " on <" << __DATE__ << ">" << endl;
    3333    gLog << "========================================================" << endl;
    3434    gLog << endl;
     
    4141    gLog << all << endl;
    4242    gLog << "Sorry the usage is:" << endl;
    43     gLog << " ganymed [options] dataset.txt" << endl << endl;
     43    gLog << " ganymed [options] dataset.txt|number" << endl << endl;
    4444    gLog << " Arguments:" << endl;
    4545    gLog << "   dataset.txt:              ASCII file defining a collection of sequences" << endl;
     46    gLog << "   number:                   The dataset number (using file in the datacenter)" << endl;
    4647    gLog << "                             For more details see MDataSet." << endl;
    4748    gLog << " Root Options:" << endl;
     
    164165    // Setup sequence file and check for its existence
    165166    //
    166     const TString kSequences = arg.GetArgumentStr(0);
     167    TString kSequences = arg.GetArgumentStr(0);
     168
     169    //
     170    // Something special for datacenter access
     171    //
     172    if (kSequences.IsDigit())
     173    {
     174        const Int_t numseq = kSequences.Atoi();
     175        kSequences = Form("/magic/datasets/%04d/dataset%08d.txt", numseq/10000, numseq);
     176        gLog << inf << "inflated dataset file: " << kSequences << endl;
     177    }
    167178
    168179    if (gSystem->AccessPathName(kSequences, kFileExists))
    169180    {
    170         gLog << err << "Sorry, sequences file '" << kSequences << "' doesn't exist." << endl;
     181        gLog << err << "Sorry, dataset file '" << kSequences << "' doesn't exist." << endl;
    171182        return 2;
    172183    }
     
    196207    if (!seq.IsValid())
    197208    {
    198         gLog << err << "Sequences read but not valid!" << endl << endl;
     209        gLog << err << "Dataset read but not valid (maybe analysis number not set)!" << endl << endl;
    199210        return 2;
    200211    }
  • trunk/MagicSoft/Mars/mars.cc

    r7179 r7432  
    3636    gLog << "                    MARS V" << MARSVER              << endl;
    3737    gLog << "    Magic Analysis and Reconstruction Software"     << endl;
    38     gLog << "   Compiled with ROOT v" << ROOTVER << " on <" << __DATE__ ">" << endl;
     38    gLog << "   Compiled with ROOT v" << ROOTVER << " on <" << __DATE__ << ">" << endl;
    3939    gLog << "==================================================" << endl;
    4040    gLog << endl;
  • trunk/MagicSoft/Mars/mastro/MAstro.cc

    r7227 r7432  
    623623    return TMath::ACos(d)*TMath::RadToDeg();
    624624}
     625
     626// --------------------------------------------------------------------------
     627//
     628// Returned is the offset (number of days) which must be added to
     629// March 1st of the given year, eg:
     630//
     631//    Int_t offset = GetDayOfEaster(2004);
     632//
     633//    MTime t;
     634//    t.Set(year, 3, 1);
     635//    t.SetMjd(t.GetMjd()+offset);
     636//
     637//    cout << t << endl;
     638//
     639//  If the date coudn't be calculated -1 is returned.
     640//
     641//  The minimum value returned is 21 corresponding to March 22.
     642//  The maximum value returned is 55 corresponding to April 25.
     643//
     644// --------------------------------------------------------------------------
     645//
     646// Gauss'sche Formel zur Berechnung des Osterdatums
     647// Wann wird Ostern gefeiert? Wie erfährt man das Osterdatum für ein
     648// bestimmtes Jahr, ohne in einen Kalender zu schauen?
     649//
     650// Ostern ist ein "bewegliches" Fest. Es wird am ersten Sonntag nach dem
     651// ersten Frühlingsvollmond gefeiert. Damit ist der 22. März der früheste
     652// Termin, der 25. April der letzte, auf den Ostern fallen kann. Von
     653// diesem Termin hängen auch die Feste Christi Himmelfahrt, das 40 Tage
     654// nach Ostern, und Pfingsten, das 50 Tage nach Ostern gefeiert wird, ab.
     655//
     656// Von Carl Friedrich Gauß (Mathematiker, Astronom und Physiker;
     657// 1777-1855) stammt ein Algorithmus, der es erlaubt ohne Kenntnis des
     658// Mondkalenders die Daten der Osterfeste für die Jahre 1700 bis 2199 zu
     659// bestimmen.
     660//
     661// Gib eine Jahreszahl zwischen 1700 und 2199 ein:
     662//
     663// Und so funktioniert der Algorithmus:
     664//
     665// Es sei:
     666//
     667// J    die Jahreszahl
     668// a    der Divisionsrest von   J/19
     669// b    der Divisionsrest von   J/4
     670// c    der Divisionsrest von   J/7
     671// d    der Divisionsrest von   (19*a + M)/30
     672// e    der Divisionsrest von   (2*b + 4*c + 6*d + N)/7
     673//
     674// wobei M und N folgende Werte annehmen:
     675//
     676// für die Jahre        M       N
     677// 1700-1799    23      3
     678// 1800-1899    23      4
     679// 1900-2099    24      5
     680// 2100-2199    24      6
     681//
     682// Dann fällt Ostern auf den
     683// (22 + d + e)ten März
     684//
     685// oder den
     686// (d + e - 9)ten April
     687//
     688// Beachte:
     689// Anstelle des 26. Aprils ist immer der 19. April zu setzen,
     690// anstelle des 25. Aprils immer dann der 18. April, wenn d=28 und a>10.
     691//
     692// Literatur:
     693// Schüler-Rechenduden
     694// Bibliographisches Institut
     695// Mannheim, 1966
     696//
     697// --------------------------------------------------------------------------
     698//
     699// Der Ostersonntag ist ein sog. unregelmäßiger Feiertag. Alle anderen
     700// unregelmäßigen Feiertage eines Jahres leiten sich von diesem Tag ab:
     701//
     702//    * Aschermittwoch ist 46 Tage vor Ostern.
     703//    * Pfingsten ist 49 Tage nach Ostern.
     704//    * Christi Himmelfahrt ist 10 Tage vor Pfingsten.
     705//    * Fronleichnam ist 11 Tage nach Pfingsten.
     706//
     707// Man muß also nur den Ostersonntag ermitteln, um alle anderen
     708// unregelmäßigen Feiertage zu berechnen. Doch wie geht das?
     709//
     710// Dazu etwas Geschichte:
     711//
     712// Das 1. Kirchenkonzil im Jahre 325 hat festgelegt:
     713//
     714//    * Ostern ist stets am ersten Sonntag nach dem ersten Vollmond des
     715//      Frühlings.
     716//    * Stichtag ist der 21. März, die "Frühlings-Tagundnachtgleiche".
     717//
     718// Am 15.10.1582 wurde von Papst Gregor XIII. der bis dahin gültige
     719// Julianische Kalender reformiert. Der noch heute gültige Gregorianische
     720// Kalender legt dabei folgendes fest:
     721//
     722// Ein Jahr hat 365 Tage und ein Schaltjahr wird eingefügt, wenn das Jahr
     723// durch 4 oder durch 400, aber nicht durch 100 teilbar ist. Hieraus
     724// ergeben sich die zwei notwendigen Konstanten, um den Ostersonntag zu
     725// berechnen:
     726//
     727//   1. Die Jahreslänge von und bis zum Zeitpunkt der
     728//      Frühlings-Tagundnachtgleiche: 365,2422 mittlere Sonnentage
     729//   2. Ein Mondmonat: 29,5306 mittlere Sonnentage
     730//
     731// Mit der "Osterformel", von Carl Friedrich Gauß (1777-1855) im Jahre 1800
     732// entwickelt, läßt sich der Ostersonntag für jedes Jahr von 1583 bis 8202
     733// berechnen.
     734//
     735// Der früheste mögliche Ostertermin ist der 22. März. (Wenn der Vollmond
     736// auf den 21. März fällt und der 22. März ein Sonntag ist.)
     737//
     738// Der späteste mögliche Ostertermin ist der 25. April. (Wenn der Vollmond
     739// auf den 21. März fällt und der 21. März ein Sonntag ist.)
     740//
     741Int_t MAstro::GetEasterOffset(UShort_t year)
     742{
     743    if (year<1700 || year>2199)
     744    {
     745        cout << "MAstro::GetDayOfEaster - Year " << year << " not between 1700 and 2199" << endl;
     746        return -1;
     747    }
     748
     749    const Int_t M = (year+2900)/200;
     750
     751    Int_t N=0;
     752    switch (year/100)
     753    {
     754    case 17: N=3; break;
     755    case 18: N=4; break;
     756    case 19:
     757    case 20: N=5; break;
     758    case 21: N=6; break;
     759    }
     760
     761    const Int_t a = year%19;
     762    const Int_t b = year%4;
     763    const Int_t c = year%7;
     764    const Int_t d = (19*a + M)%30;
     765    const Int_t e = (2*b + 4*c + 6*d + N)%7;
     766
     767    if (e==6 && d==28 && a>10)
     768        return 48;
     769
     770    if (d+e==35)
     771        return 49;
     772
     773    return d + e + 21;
     774}
  • trunk/MagicSoft/Mars/mastro/MAstro.h

    r7202 r7432  
    1010
    1111class TVector3;
     12class MTime;
    1213
    1314class MAstro
     
    7677    static Double_t GetDevAbs(Double_t nomzd, Double_t devzd, Double_t devaz);
    7778
     79    static Int_t GetEasterOffset(UShort_t year);
     80
    7881    ClassDef(MAstro, 0)
    7982};
  • trunk/MagicSoft/Mars/mbase/MEnv.cc

    r6553 r7432  
    3434#include "MEnv.h"
    3535
     36#include <Gtypes.h>
    3637#include <TObjString.h>
     38
     39#include <TAttText.h>
     40#include <TAttFill.h>
     41#include <TAttLine.h>
     42#include <TAttMarker.h>
    3743
    3844#include "MLog.h"
     
    6268        fChecked.Add(new TObjString(name));
    6369    return TEnv::GetValue(name, dflt);
     70}
     71
     72Int_t MEnv::GetColor(const char *name, Int_t dftl)
     73{
     74    TString str = GetValue(name, "");
     75
     76    str = str.Strip(TString::kBoth);
     77    if (str.IsNull())
     78        return dftl;
     79
     80    str.ToLower();
     81
     82    switch (str.Hash())
     83    {
     84    case (unsigned)-1926423925/*2368543371*/: return kWhite;
     85    case 1814927399: return kBlack;
     86    case 7496964:    return kRed;
     87    case (unsigned)-1397860222/*2897107074*/: return kGreen;
     88    case 1702194402: return kBlue;
     89    case (unsigned)-1920149414/* 2374817882*/: return kYellow;
     90    case (unsigned)-1400748595/*2894218701*/: return kMagenta;
     91    case 1851881955: return kCyan;
     92    case 749623518: return 18; // grey1
     93    case 749623517: return 17; // grey2
     94    case 749623516: return 16; // grey3
     95    case 749623515: return 15; // grey4
     96    case 749623514: return 14; // grey5
     97    case 741234910: return 18; // gray1
     98    case 741234909: return 17; // gray2
     99    case 741234908: return 16; // gray3
     100    case 741234907: return 15; // gray4
     101    case 741234906: return 14; // gray5
     102    }
     103    return str.Atoi();
     104}
     105
     106TString MEnv::Compile(TString str, const char *post) const
     107{
     108    if (!str.IsNull() && str[str.Length()-1]!='.')
     109        str += ".";
     110
     111    str += post;
     112
     113    return str;
     114}
     115
     116void MEnv::GetAttLine(const char *name, TAttLine &line, TAttLine *dftl)
     117{
     118    const TString color = Compile(name, "LineColor");
     119    const TString style = Compile(name, "LineStyle");
     120    const TString width = Compile(name, "LineWidth");
     121
     122    if (!dftl)
     123        dftl = &line;
     124
     125    const Color_t col = GetColor(color, dftl->GetLineColor());
     126    const Style_t sty = GetValue(style, dftl->GetLineStyle());
     127    const Style_t wid = GetValue(width, dftl->GetLineWidth());
     128
     129    line.SetLineColor(col);
     130    line.SetLineStyle(sty);
     131    line.SetLineWidth(wid);
     132}
     133
     134void MEnv::GetAttText(const char *name, TAttText &text, TAttText *dftl)
     135{
     136   const TString color = Compile(name, "TextColor");
     137   const TString align = Compile(name, "TextAlign");
     138   const TString angle = Compile(name, "TextAngle");
     139   const TString font  = Compile(name, "TextFont");
     140   const TString size  = Compile(name, "TextSize");
     141
     142    if (!dftl)
     143        dftl = &text;
     144
     145    const Color_t col = GetColor(color, dftl->GetTextColor());
     146    const Short_t ali = GetValue(align, dftl->GetTextAlign());
     147    const Float_t ang = GetValue(angle, dftl->GetTextAngle());
     148    const Font_t  fon = GetValue(font,  dftl->GetTextFont());
     149    const Float_t siz = GetValue(size,  dftl->GetTextSize());
     150
     151    text.SetTextColor(col);
     152    text.SetTextAlign(ali);
     153    text.SetTextAngle(ang);
     154    text.SetTextFont(fon);
     155    text.SetTextSize(siz);
     156}
     157
     158void MEnv::GetAttFill(const char *name, TAttFill &fill, TAttFill *dftl)
     159{
     160    const TString color = Compile(name, "FillColor");
     161    const TString style = Compile(name, "FillStyle");
     162
     163    if (!dftl)
     164        dftl = &fill;
     165
     166    const Color_t col = GetColor(color, dftl->GetFillColor());
     167    const Style_t sty = GetValue(style, dftl->GetFillStyle());
     168
     169    fill.SetFillColor(col);
     170    fill.SetFillStyle(sty);
     171}
     172
     173void MEnv::GetAttMarker(const char *name, TAttMarker &marker, TAttMarker *dftl)
     174{
     175    const TString color = Compile(name, "MarkerColor");
     176    const TString style = Compile(name, "MarkerStyle");
     177    const TString size  = Compile(name, "MarkerSize");
     178
     179    if (!dftl)
     180        dftl = &marker;
     181
     182    const Color_t col = GetColor(color, dftl->GetMarkerColor());
     183    const Style_t sty = GetValue(style, dftl->GetMarkerStyle());
     184    const Size_t  siz = GetValue(size,  dftl->GetMarkerSize());
     185
     186    marker.SetMarkerColor(col);
     187    marker.SetMarkerStyle(sty);
     188    marker.SetMarkerSize(siz);
     189}
     190
     191void MEnv::GetAttributes(const char *name, TObject *obj, TObject *dftl)
     192{
     193    //TAttAxis         *line = dynamic_cast<TAttAxis*>(obj);
     194    //TAtt3D           *line = dynamic_cast<TAtt3D*>(obj);
     195    //TAttCanvas       *line = dynamic_cast<TAttCanvas*>(obj);
     196    //TAttFillCanvas   *line = dynamic_cast<TAttFillEitor*>(obj);
     197    //TAttLineCanvas   *line = dynamic_cast<TAttLineCanvas*>(obj);
     198    //TAttLineEditor   *line = dynamic_cast<TAttLineEditor*>(obj);
     199    //TAttMarkerCanvas *line = dynamic_cast<TAttMarkerCanvas*>(obj);
     200    //TAttMarkerEditor *line = dynamic_cast<TAttMarkerEditor*>(obj);
     201    //TAttPad          *line = dynamic_cast<TAttPad*>(obj);
     202    //TAttParticle     *line = dynamic_cast<TAttParticle*>(obj);
     203    //TAttTextCanvas   *line = dynamic_cast<TAttTextCanvas*>(obj);
     204    //TAttTextEditor   *line = dynamic_cast<TAttTextEditor*>(obj);
     205
     206    TAttLine   *line = dynamic_cast<TAttLine*>(/*(TAttLine*)*/obj);
     207    TAttText   *text = dynamic_cast<TAttText*>(/*(TAttText*)*/obj);
     208    TAttFill   *fill = dynamic_cast<TAttFill*>(/*(TAttFill*)*/obj);
     209    TAttMarker *mark = dynamic_cast<TAttMarker*>(/*(TAttMarker*)*/obj);
     210
     211    cout << line << " " << text << " " << fill << " " << mark << endl;
     212
     213    if (line)
     214        GetAttLine(name, *line, dynamic_cast<TAttLine*>(/*(TAttLine*)*/dftl));
     215    if (text)
     216        GetAttText(name, *text, dynamic_cast<TAttText*>(/*(TAttText*)*/dftl));
     217    if (fill)
     218        GetAttFill(name, *fill, dynamic_cast<TAttFill*>(/*(TAttFill*)*/dftl));
     219    if (mark)
     220        GetAttMarker(name, *mark, dynamic_cast<TAttMarker*>(/*(TAttMarker*)*/dftl));
    64221}
    65222
  • trunk/MagicSoft/Mars/mbase/MEnv.h

    r6553 r7432  
    1010#endif
    1111
     12class TAttLine;
     13class TAttMarker;
     14class TAttText;
     15class TAttFill;
     16
    1217class MEnv : public TEnv
    1318{
    1419private:
    1520    TOrdCollection fChecked;
     21
     22    TString Compile(TString str, const char *post) const;
    1623
    1724public:
     
    2229    const char *GetValue(const char *name, const char *dflt);
    2330
     31    Int_t       GetColor(const char *name, Int_t dftl);
     32
     33    void        GetAttributes(const char *name, TObject *obj, TObject *dftl=0);
     34    void        GetAttLine(const char *name, TAttLine &line, TAttLine *dftl=0);
     35    void        GetAttText(const char *name, TAttText &text, TAttText *dftl=0);
     36    void        GetAttFill(const char *name, TAttFill &fill, TAttFill *dftl=0);
     37    void        GetAttMarker(const char *name, TAttMarker &marker, TAttMarker *dftl=0);
     38
    2439    void PrintUntouched() const;
    2540
  • trunk/MagicSoft/Mars/mbase/MTime.cc

    r7384 r7432  
    239239{
    240240    SetMjd(time*1000/kDay+49718);
     241}
     242
     243// --------------------------------------------------------------------------
     244//
     245// Set this to the date of easter corresponding to the given year.
     246// If calculation was not possible it is set to MTime()
     247//
     248// The date corresponding to the year of MTime(-1) is returned
     249// if year<0
     250//
     251// The date corresponding to the Year() is returned if year==0.
     252//
     253//  for more information see: GetEaster and MAstro::GetEasterOffset()
     254//
     255void MTime::SetEaster(Short_t year)
     256{
     257    *this = GetEaster(year==0 ? Year() : year);
    241258}
    242259
     
    515532// The maximum size of the return string is 128 (incl. NULL)
    516533//
    517 TString MTime::GetStringFmt(const char *fmt) const
     534// For dates before 1.1.1902  a null string is returned
     535// For dates after 31.12.2037 a null string is returned
     536//
     537// To change the localization use loc, eg loc = "da_DK", "de_DE".
     538// Leaving the argument empty will just take the default localization.
     539//
     540// If loc is "", each part of the locale that should be modified is set
     541// according  to the environment variables. The details are implementation
     542// dependent.  For glibc, first (regardless of category), the  environment
     543// variable  LC_ALL  is  inspected, next the environment variable with the
     544// same name as the category (LC_COLLATE, LC_CTYPE, LC_MESSAGES,  LC_MONE?
     545// TARY,  LC_NUMERIC,  LC_TIME) and finally the environment variable LANG.
     546// The first existing environment variable is used.
     547//
     548// A  locale  name  is  typically  of the form language[_territory][.code?
     549// set][@modifier], where language is an ISO 639 language code,  territory
     550// is an ISO 3166 country code, and codeset is a character set or encoding
     551// identifier like ISO-8859-1 or UTF-8.   For  a  list  of  all  supported
     552// locales, try "locale -a", cf. locale(1).
     553//
     554TString MTime::GetStringFmt(const char *fmt, const char *loc) const
    518555{
    519556    if (!fmt)
     
    525562    GetDate(y, mon, d);
    526563    GetTime(h, m, s, ms);
     564
     565    if (y<1902 || y>2037)
     566        return "";
    527567
    528568    struct tm time;
     
    535575    time.tm_isdst = 0;
    536576
     577    const TString locale = setlocale(LC_TIME, 0);
     578
     579    setlocale(LC_TIME, loc);
     580
    537581    // recalculate tm_yday and tm_wday
    538582    mktime(&time);
    539583
    540584    char ret[128];
    541     return TString(strftime(ret, 127, fmt, &time) ? ret : "");
     585    const size_t rc = strftime(ret, 127, fmt, &time);
     586
     587    setlocale(LC_TIME, locale);
     588
     589    return rc ? ret : "";
    542590}
    543591
     
    549597// For more information see GetStringFmt
    550598//
    551 Bool_t MTime::SetStringFmt(const char *time, const char *fmt)
     599Bool_t MTime::SetStringFmt(const char *time, const char *fmt, const char *loc)
    552600{
    553601    if (!fmt)
     
    556604    struct tm t;
    557605    memset(&t, 0, sizeof(struct tm));
     606
     607    const TString locale = setlocale(LC_TIME, 0);
     608
     609    setlocale(LC_TIME, loc);
    558610    strptime(time, fmt, &t);
     611    setlocale(LC_TIME, locale);
    559612
    560613    return Set(t.tm_year+1900, t.tm_mon+1, t.tm_mday, t.tm_hour, t.tm_min, t.tm_sec);
     
    795848    return out;
    796849}
     850
     851// --------------------------------------------------------------------------
     852//
     853// Calculate the day of easter for the given year.
     854// MTime() is returned if this was not possible.
     855//
     856// In case of the default argument or the year less than zero
     857// the date of eastern of the current year (the year corresponding to
     858// MTime(-1)) is returned.
     859//
     860//  for more information see: MAstro::GetDayOfEaster()
     861//
     862MTime MTime::GetEaster(Short_t year)
     863{
     864    if (year<0)
     865        year = MTime(-1).Year();
     866
     867    const Int_t day = MAstro::GetEasterOffset(year);
     868    if (day<0)
     869        return MTime();
     870
     871    MTime t;
     872    t.Set(year, 3, 1);
     873    t.SetMjd(t.GetMjd() + day);
     874
     875    return t;
     876}
  • trunk/MagicSoft/Mars/mbase/MTime.h

    r7384 r7432  
    8383    Bool_t   SetSqlTimeStamp(const char *str);
    8484    void     SetCT1Time(UInt_t mjd, UInt_t t1, UInt_t t0);
    85     Bool_t   SetStringFmt(const char *time, const char *fmt);
     85    Bool_t   SetStringFmt(const char *time, const char *fmt, const char *loc=0);
    8686    Bool_t   UpdMagicTime(Byte_t h, Byte_t m, Byte_t s, UInt_t ns);
    8787    Bool_t   SetMjd(UInt_t mjd, ULong_t ms, UInt_t ns=0);
    8888    void     SetMjd(Double_t m);
    8989    void     SetAxisTime(Double_t time);
     90    void     SetEaster(Short_t year=0);
    9091
    9192    // Getter functions
     
    9394    Double_t GetGmst() const;
    9495    TString  GetString() const;
    95     TString  GetStringFmt(const char *fmt=0) const;
     96    TString  GetStringFmt(const char *fmt=0, const char *loc=0) const;
    9697    TString  GetSqlDateTime() const;
    9798    TString  GetSqlTimeStamp() const;
     
    112113    }
    113114
    114     UInt_t Year() const  { UShort_t y; Byte_t m, d; GetDate(y,m,d); return y; }
    115     UInt_t Month() const { UShort_t y; Byte_t m, d; GetDate(y,m,d); return m; }
    116     UInt_t Day() const   { UShort_t y; Byte_t m, d; GetDate(y,m,d); return d; }
    117     UInt_t Hour() const  { Byte_t h, m, s; GetTime(h,m,s); return h; }
    118     UInt_t Min() const   { Byte_t h, m, s; GetTime(h,m,s); return m; }
    119     UInt_t Sec() const   { Byte_t h, m, s; GetTime(h,m,s); return s; }
     115    UInt_t Year() const    { UShort_t y; Byte_t m, d; GetDate(y,m,d); return y; }
     116    UInt_t Month() const   { UShort_t y; Byte_t m, d; GetDate(y,m,d); return m; }
     117    UInt_t Day() const     { UShort_t y; Byte_t m, d; GetDate(y,m,d); return d; }
     118    Byte_t WeekDay() const { return TMath::Nint(TMath::Floor(GetMjd()+3))%7; } // Return Day of the week: Sun=0, Mon=1, ..., Sat=6
     119    UInt_t Hour() const    { Byte_t h, m, s; GetTime(h,m,s); return h; }
     120    UInt_t Min() const     { Byte_t h, m, s; GetTime(h,m,s); return m; }
     121    UInt_t Sec() const     { Byte_t h, m, s; GetTime(h,m,s); return s; }
    120122
    121123    Bool_t IsMidnight() const { return (Long_t)fTime==0 && fNanoSec==0; }
     
    155157    bool operator!() const;
    156158
     159    static MTime GetEaster(Short_t year=-1);
     160
    157161    ClassDef(MTime, 3)  //A generalized MARS time stamp
    158162};
  • trunk/MagicSoft/Mars/merpp.cc

    r7430 r7432  
    5353    gLog << "                MERPP - MARS V" << MARSVER          << endl;
    5454    gLog << "     MARS - Merging and Preprocessing Program"      << endl;
    55     gLog << "   Compiled with ROOT v" << ROOTVER << " on <" << __DATE__ ">" << endl;
     55    gLog << "   Compiled with ROOT v" << ROOTVER << " on <" << __DATE__ << ">" << endl;
    5656    gLog << "==================================================" << endl;
    5757    gLog << endl;
  • trunk/MagicSoft/Mars/mjobs/MJCut.cc

    r7425 r7432  
    356356    write->AddContainer("MNewImagePar",   "Events", kFALSE);
    357357    write->AddContainer("MNewImagePar2",  "Events", kFALSE);
    358     write->AddContainer("MHadronness",    "Events", kFALSE);
     358    write->AddContainer("Hadronness",     "Events", kFALSE);
    359359    write->AddContainer("MSrcPosCam",     "Events", kFALSE);
    360360    write->AddContainer("MSrcPosAnti",    "Events", kFALSE);
  • trunk/MagicSoft/Mars/readdaq.cc

    r7091 r7432  
    3939    gLog << "              ReadDaq - MARS V" << MARSVER          << endl;
    4040    gLog << "       MARS - Read and print daq data files"        << endl;
    41     gLog << "   Compiled with ROOT v" << ROOTVER << " on <" << __DATE__ ">" << endl;
     41    gLog << "   Compiled with ROOT v" << ROOTVER << " on <" << __DATE__ << ">" << endl;
    4242    gLog << "==================================================" << endl;
    4343    gLog << endl;
  • trunk/MagicSoft/Mars/readraw.cc

    r7091 r7432  
    4242    gLog << "              ReadRaw - MARS V" << MARSVER          << endl;
    4343    gLog << "       MARS - Read and print raw data files"        << endl;
    44     gLog << "   Compiled with ROOT v" << ROOTVER << " on <" << __DATE__ ">" << endl;
     44    gLog << "   Compiled with ROOT v" << ROOTVER << " on <" << __DATE__ << ">" << endl;
    4545    gLog << "==================================================" << endl;
    4646    gLog << endl;
  • trunk/MagicSoft/Mars/showlog.cc

    r7179 r7432  
    1111using namespace std;
    1212
     13static void StartUpMessage()
     14{
     15    //                1         2         3         4         5
     16    //       12345678901234567890123456789012345678901234567890
     17    gLog << endl;
     18    gLog << "showlog --- Mars V" << MARSVER << " compiled on <" << __DATE__ << "> using ROOT v" << ROOTVER << endl;
     19    gLog << endl;
     20}
     21
    1322static void Usage()
    1423{
    1524    gLog << endl;
    1625    gLog << "Sorry the usage is:" << endl;
    17     gLog << "   showlog [options] filename" << endl;
     26    gLog << "   showlog [options] {filename}|{location number}" << endl;
    1827    gLog << " or" << endl;
    1928    gLog << "   showlog [options] < filename" << endl << endl;
     29    gLog << " Arguments:" << endl;
     30    gLog << "   filename                  Input log file" << endl;
     31    gLog << "   location number           Open file from location callisto, star, etc." << endl;
     32    gLog << "                             of sequence or dataset number" << endl << endl;
    2033    gLog.Usage();
    2134    gLog << "   --version, -V             Show startup message with version number" << endl;
     
    5265
    5366    if (arg.HasOnly("-V") || arg.HasOnly("--version"))
     67    {
     68        StartUpMessage();
    5469        return 0;
     70    }
    5571
    5672    if (arg.HasOnly("-?") || arg.HasOnly("-h") || arg.HasOnly("--help"))
     
    7490    // check for the right usage of the program
    7591    //
    76     if (arg.GetNumArguments()>1)
     92    if (arg.GetNumArguments()>2)
    7793    {
    7894        Usage();
     
    8096    }
    8197
     98    //
     99    // Something special for datacenter access
     100    //
     101    TString kInput = arg.GetArgumentStr(0);
     102    if (arg.GetNumArguments()==2)
     103    {
     104        const Int_t num = arg.GetArgumentStr(1).Atoi();
     105        TString file = "/magic/data/";
     106        file += kInput;
     107        file += Form("/%04d/%08d/", num/10000, num);
     108        file += kInput;
     109        file += Form("%08d.log", num);
     110
     111        kInput = file;
     112
     113        gLog << inf << "Inflated file name: " << kInput << endl;
     114    }
     115
     116
    82117    // casts necessary for gcc 2.95.3
    83     istream *in = arg.GetNumArguments()==1 ? (istream*)new ifstream(arg.GetArgumentStr(0)) : (istream*)&cin;
     118    istream *in = arg.GetNumArguments()>0 ? (istream*)new ifstream(kInput) : (istream*)&cin;
    84119    if (!*in)
    85120    {
    86         gLog << "Cannot open file " << arg.GetArgumentStr(0) << ": " << strerror(errno) << endl;
     121        gLog << err << "Cannot open file " << kInput << ": " << strerror(errno) << endl;
    87122        return 2;
    88123    }
  • trunk/MagicSoft/Mars/showplot.cc

    r7179 r7432  
    2828    gLog << all << endl;
    2929    gLog << "Sorry the usage is:" << endl;
    30     gLog << " showplot [options] filename" << endl << endl;
     30    gLog << " showplot [options] {filename}|{filetype number}" << endl << endl;
    3131    gLog << " Arguments:" << endl;
    32     gLog << "   filename                  Input file containing an MStatusArray" << endl << endl;
     32    gLog << "   filename                  Input file containing an MStatusArray" << endl;
     33    gLog << "   filetype number           Open file of filetype calib, signal, star, etc." << endl;
     34    gLog << "                             of sequence or dataset number" << endl << endl;
    3335    gLog << " Root Options:" << endl;
    3436    gLog << "   -b                        Batch mode (no graphical output to screen)" << endl<<endl;
     
    135137        return 3;
    136138    }
    137     if (arg.GetNumArguments()!=1)
     139    if (arg.GetNumArguments()<1 || arg.GetNumArguments()>2 || !arg.GetArgumentStr(1).IsDigit())
    138140    {
    139141        Usage();
     
    151153    // Process filenames
    152154    //
    153     const TString kInput = arg.GetArgumentStr(0);
     155    TString kInput = arg.GetArgumentStr(0);
     156
     157    //
     158    // Something special for datacenter access
     159    //
     160    if (arg.GetNumArguments()==2)
     161    {
     162        const Int_t num = arg.GetArgumentStr(1).Atoi();
     163        TString file = "/magic/data/";
     164        switch (kInput.Hash())
     165
     166        {
     167        case (unsigned long)-856860927:
     168        case  764164111:
     169            file += "callisto";
     170            break;
     171        default:
     172            file += kInput;
     173            break;
     174        }
     175        file += Form("/%04d/%08d/", num/10000, num);
     176        file += kInput;
     177        file += Form("%08d.root", num);
     178
     179        kInput = file;
     180
     181        gLog << inf << "Inflated file name: " << kInput << endl;
     182    }
    154183
    155184    if (kNamePs.IsNull()    && kSaveAsPs)
  • trunk/MagicSoft/Mars/sponde.cc

    r7179 r7432  
    3030    gLog << "                  Sponde - MARS V" << MARSVER             << endl;
    3131    gLog << "               MARS -- SPectrum ON DEmand"                << endl;
    32     gLog << "   Compiled with ROOT v" << ROOTVER << " on <" << __DATE__ ">" << endl;
     32    gLog << "   Compiled with ROOT v" << ROOTVER << " on <" << __DATE__ << ">" << endl;
    3333    gLog << "========================================================" << endl;
    3434    gLog << endl;
  • trunk/MagicSoft/Mars/star.cc

    r7091 r7432  
    3030    gLog << "                   Star - MARS V" << MARSVER              << endl;
    3131    gLog << "      MARS -- STandard Analysis and Reconstruction"       << endl;
    32     gLog << "   Compiled with ROOT v" << ROOTVER << " on <" << __DATE__ ">" << endl;
     32    gLog << "   Compiled with ROOT v" << ROOTVER << " on <" << __DATE__ << ">" << endl;
    3333    gLog << "========================================================" << endl;
    3434    gLog << endl;
     
    4141    gLog << all << endl;
    4242    gLog << "Sorry the usage is:" << endl;
    43     gLog << " star [options] sequence.txt" << endl << endl;
     43    gLog << " star [options] sequence.txt|number" << endl << endl;
    4444    gLog << " Arguments:" << endl;
    4545    gLog << "   sequence.txt:             Ascii file defining a sequence of runs" << endl;
     46    gLog << "   number:                   The sequence number (using file in the datacenter)" << endl;
    4647    gLog << "                             For more details see MSequence" << endl;
    4748    gLog << " Root Options:" << endl;
     
    146147    // Setup sequence file and check for its existance
    147148    //
    148     const TString kSequence = arg.GetArgumentStr(0);
     149    TString kSequence = arg.GetArgumentStr(0);
     150
     151    //
     152    // Something special for datacenter access
     153    //
     154    if (kSequence.IsDigit())
     155    {
     156        const Int_t numseq = kSequence.Atoi();
     157        kSequence = Form("/magic/sequences/%04d/sequence%08d.txt", numseq/10000, numseq);
     158        gLog << inf << "Inflated sequence file: " << kSequence <<  endl;
     159    }
    149160
    150161    if (gSystem->AccessPathName(kSequence, kFileExists))
Note: See TracChangeset for help on using the changeset viewer.