Ignore:
Timestamp:
07/31/08 17:41:29 (16 years ago)
Author:
tbretz
Message:
*** empty log message ***
Location:
trunk/MagicSoft/Mars/datacenter/macros
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • trunk/MagicSoft/Mars/datacenter/macros/checkstardone.C

    r9018 r9062  
    7272    // -------------------------------------------
    7373
    74     TString query = "NOT ISNULL(fStar) FROM SequenceProcessStatus "
     74    TString query = "SELECT MIN(NOT ISNULL(fStar)) FROM SequenceProcessStatus "
    7575        "LEFT JOIN DataSetSequenceMapping USING (fTelescopeNumber,fSequenceFirst) ";
    7676    query += Form("WHERE fDataSetNumber=%d", num);
     
    8787    }
    8888
    89     TSQlRow *row = res->Next();
     89    TSQLRow *row = res->Next();
    9090
    9191    if (!row || !(*row)[0])
  • trunk/MagicSoft/Mars/datacenter/macros/fillcalib.C

    r8951 r9062  
    6161#include <iostream>
    6262
    63 #include <TEnv.h>
    64 #include <TRegexp.h>
    65 
    6663#include <TH1.h>
    6764
     
    7471#include "MStatusArray.h"
    7572#include "MHCamera.h"
     73#include "MSequence.h"
    7674#include "MGeomCamMagic.h"
    7775#include "MBadPixelsCam.h"
     
    145143    if (!h)
    146144    {
    147         cout << "WARNING - Could not find histogram HRelTimeHiGainArea0." << endl;
     145        cout << "ERROR - Could not find histogram HRelTimeHiGainArea0 in Time." << endl;
    148146        return 2;
    149147    }
     
    156154    if (!h)
    157155    {
    158         cout << "WARNING - Could not find histogram HRelTimeHiGainArea1." << endl;
     156        cout << "ERROR - Could not find histogram HRelTimeHiGainArea1 in Time." << endl;
    159157        return 2;
    160158    }
     
    167165    if (!c)
    168166    {
    169         cout << "WARNING - Could not find MHCamera TotalConv." << endl;
     167        cout << "ERROR - Could not find MHCamera TotalConv in Conversion." << endl;
    170168        return 2;
    171169    }
     
    182180    TString meanconvouter=Form("%6.3f", meanconvo);
    183181
    184     //Getting sequ# from filename
    185     TString sequence = fname(TRegexp("calib[0-9]+[.]root$"));
    186     if (sequence.IsNull())
    187     {
    188         cout << "WARNING - Could get sequence# from filename: " << fname << endl;
    189         return 2;
    190     }
    191 
    192     Int_t seq = atoi(sequence.Data()+5);
     182    //Getting relative charge rms
     183    c = (MHCamera*)arr.FindObjectInCanvas("RMSperMean", "MHCamera", "FitCharge");
     184    if (!c)
     185    {
     186        cout << "ERROR - Could not find MHCamera RMSperMean in FitCharge." << endl;
     187        return 2;
     188    }
     189
     190    Stat_t relrmsi = c->GetMedianSectors(TArrayI(6, s0), inner);
     191    Stat_t relrmso = c->GetMedianSectors(TArrayI(6, s0), outer);
     192    TString relrmsinner=Form("%6.3f", relrmsi);
     193    TString relrmsouter=Form("%6.3f", relrmso);
     194
     195    //Getting relative charge rms
     196    c = (MHCamera*)arr.FindObjectInCanvas("NumPhes", "MHCamera", "FitCharge");
     197    if (!c)
     198    {
     199        cout << "ERROR - Could not find MHCamera NumPhes in FitCharge." << endl;
     200        return 2;
     201    }
     202
     203    Stat_t numphei = c->GetMedianSectors(TArrayI(6, s0), inner);
     204    Stat_t numpheo = c->GetMedianSectors(TArrayI(6, s0), outer);
     205    TString numpheinner=Form("%5.1f", numphei);
     206    TString numpheouter=Form("%5.1f", numpheo);
     207
     208    MSequence seq;
     209    if (seq.Read("sequence[0-9]{8}[.]txt|MSequence")<=0)
     210    {
     211        cout << "ERROR - Could not find sequence in file: " << fname << endl;
     212        return 2;
     213    }
     214    if (!seq.IsValid())
     215    {
     216        cout << "ERROR - Sequence read from file inavlid: " << fname << endl;
     217        return 2;
     218    }
    193219
    194220    //getting the ratio of calibration events used
     
    196222    if (!h)
    197223    {
    198         cout << "WARNING - Could not find histogram ArrTime;avg." << endl;
    199         return 2;
    200     }
    201 
    202     UInt_t nevts = h->GetEntries();
     224        cout << "ERROR - Could not find histogram ArrTime;avg." << endl;
     225        return 2;
     226    }
     227
     228    UInt_t nevts = TMath::Nint(h->GetEntries());
    203229
    204230    TString query;
    205231    query = Form("SELECT SUM(fNumEvents) FROM RunData "
    206                  "LEFT JOIN RunType ON RunType.fRunTypeKEY=RunData.fRunTypeKEY "
    207                  "WHERE fSequenceFirst=%d AND RunType.fRunTypeName='Calibration'",
    208                  seq);
     232                 "LEFT JOIN RunType USING (fRunTypeKEY) "
     233                 "WHERE fSequenceFirst=%d AND fTelescopeNumber=%d AND "
     234                 "RunType.fRunTypeName='Calibration'",
     235                 seq.GetSequence(), seq.GetTelescope());
    209236
    210237    TSQLResult *res = serv.Query(query);
     
    228255    delete res;
    229256
    230     cout << "Sequence #" << seq << endl;
    231     cout << "  Unsuitable: (i/o) " << Form("%3d %3d", (int)unsin, (int)unsout) << endl; // Unbrauchbar
    232     cout << "  Unreliable: (i/o) " << Form("%3d %3d", (int)unrin, (int)unrout) << endl; // Unzuverlaessig
    233     cout << "  Isolated:   (i/o) " << Form("%3d %3d", (int)isoin, (int)isoout) << endl; // Isolated (unbrauchbar)
    234     cout << "  Max.Cluster:      " << Form("%3d", (int)clumax)                 << endl; // Max Cluster
    235     cout << "  Arr Time inner:    " << meaninner << " +- " << rmsinner  << endl;
    236     cout << "  Arr Time outer:    " << meanouter << " +- " << rmsouter  << endl;
    237     cout << "  Mean Conv inner:   " << meanconvinner << endl;
    238     cout << "  Mean Conv outer:   " << meanconvouter << endl;
    239     cout << "  Ratio Calib Evts:  " << ratiocal << endl;
     257    cout << "Sequence M" << seq.GetTelescope() << ":" << seq.GetSequence() << endl;
     258    cout << "  Unsuitable: (i/o)  " << Form("%3d %3d", (int)unsin, (int)unsout) << endl; // Unbrauchbar
     259    cout << "  Unreliable: (i/o)  " << Form("%3d %3d", (int)unrin, (int)unrout) << endl; // Unzuverlaessig
     260    cout << "  Isolated:   (i/o)  " << Form("%3d %3d", (int)isoin, (int)isoout) << endl; // Isolated (unbrauchbar)
     261    cout << "  Max.Cluster:       " << Form("%3d", (int)clumax)                 << endl; // Max Cluster
     262    cout << "  Arr Time inner:     " << meaninner << " +- " << rmsinner  << endl;
     263    cout << "  Arr Time outer:     " << meanouter << " +- " << rmsouter  << endl;
     264    cout << "  Mean Conv inner:     " << meanconvinner << endl;
     265    cout << "  Mean Conv outer:     " << meanconvouter << endl;
     266    cout << "  Rel.charge rms in:   " << relrmsinner << endl;
     267    cout << "  Rel.charge rms out:  " << relrmsouter << endl;
     268    cout << "  Med. num phe inner: " << numpheinner << endl;
     269    cout << "  Med. num phe outer: " << numpheouter << endl;
     270    cout << "  Ratio Calib Evts:   " << ratiocal << endl;
     271
     272    // FIXME: Fill calibration charge
    240273
    241274    //inserting or updating the information in the database
    242275    TString vars =
    243         Form(" fUnsuitableInner=%d, "
     276        Form(" fSequenceFirst=%d, "
     277             " fTelescopeNumber=%d, "
     278             " fUnsuitableInner=%d, "
    244279             " fUnsuitableOuter=%d, "
    245280             " fUnreliableInner=%d, "
     
    254289             " fConvFactorInner=%s, "
    255290             " fConvFactorOuter=%s, "
    256              " fRatioCalEvents=%s ",
     291             " fRatioCalEvents=%s, "
     292             " fRelChargeRmsInner=%s, "
     293             " fRelChargeRmsOuter=%s, "
     294             " fMedNumPheInner=%s, "
     295             " fMedNumPheOuter=%s ",
     296             seq.GetSequence(), seq.GetTelescope(),
    257297             (int)unsin, (int)unsout, (int)unrin,
    258298             (int)unrout, (int)isoin, (int)isoout, (int)clumax,
     
    260300             meanouter.Data(), rmsouter.Data(),
    261301             meanconvinner.Data(), meanconvouter.Data(),
    262              ratiocal.Data());
    263 
    264     return serv.InsertUpdate("Calibration", "fSequenceFirst",
    265                              Form("%d", seq), vars.Data()) ? 1 : 2;
     302             ratiocal.Data(),
     303             relrmsinner.Data(), relrmsouter.Data(),
     304             numpheinner.Data(), numpheouter.Data()
     305            );
     306
     307    TString where = Form("fSequenceFirst=%d AND fTelescopeNumber=%d",
     308                         seq.GetSequence(), seq.GetTelescope());
     309
     310    return serv.InsertUpdate("Calibration", vars, where) ? 1 : 2;
    266311}
    267312
    268313int fillcalib(TString fname, Bool_t dummy=kTRUE)
    269314{
    270     TEnv env("sql.rc");
    271 
    272     MSQLMagic serv(env);
     315    MSQLMagic serv("sql.rc");
    273316    if (!serv.IsConnected())
    274317    {
  • trunk/MagicSoft/Mars/datacenter/macros/fillsignal.C

    r9005 r9062  
    6969
    7070#include "MStatusArray.h"
     71#include "MSequence.h"
    7172#include "MHCamera.h"
    7273#include "MHVsTime.h"
     
    140141*/
    141142
    142     //get sequence number from the filename
    143     TString sequence = fname(TRegexp("signal[0-9]+[.]root$"));
    144     if (sequence.IsNull())
    145     {
    146         cout << "ERROR - Sequ# empty" << endl;
    147         cout << "Sequ# " << sequence << endl;
    148         return 2;
    149     }
    150 
    151     Int_t seq = atoi(sequence.Data()+6);
     143    MSequence seq;
     144    if (seq.Read("sequence[0-9]{8}[.]txt|MSequence")<=0)
     145    {
     146        cout << "ERROR - Could not find sequence in file: " << fname << endl;
     147        return 2;
     148    }
     149    if (!seq.IsValid())
     150    {
     151        cout << "ERROR - Sequence read from file inavlid: " << fname << endl;
     152        return 2;
     153    }
    152154
    153155    TString medpuloff("NULL");
     
    156158    TString devhilocal("NULL");
    157159
    158     if (seq < 200000)
     160    if (seq.GetSequence()<200000 && seq.GetTelescope()==1)
    159161    {
    160162        MHCamera *hilooff = (MHCamera*)arr.FindObjectInCanvas("HiLoOff;avg", "MHCamera", "HiLoOff");
     
    313315    // *****************************************************
    314316
    315     cout << "Sequence #" << seq << endl;
     317    cout << "Sequence M" << seq.GetTelescope() << "/" << seq.GetSequence() << endl;
    316318    cout << "  Mean Ped RMS inner [phe] " << meanrmsinner  << endl;
    317319    cout << "  Mean Ped RMS outer [phe] " << meanrmsouter  << endl;
     
    374376                       );
    375377
    376 
    377     return serv.Update("Calibration", vars, Form("fSequenceFirst=%d", seq)) ? 1 : 2;
     378    TString where = Form("fSequenceFirst=%d AND fTelescopeNumber=%d",
     379                         seq.GetSequence(), seq.GetTelescope());
     380    return serv.Update("Calibration", vars, where) ? 1 : 2;
    378381}
    379382
  • trunk/MagicSoft/Mars/datacenter/macros/fillstar.C

    r8996 r9062  
    5959#include <iomanip>
    6060
    61 #include <TRegexp.h>
    62 
     61#include <TFile.h>
    6362#include <TH1.h>
    6463#include <TH2.h>
    6564#include <TGraph.h>
    66 #include <TProfile.h>
    67 #include <TFile.h>
    68 #include <TSQLResult.h>
    69 #include <TSQLRow.h>
    7065
    7166#include "MSQLMagic.h"
     
    7368#include "MHCamera.h"
    7469#include "MHMuonPar.h"
     70#include "MSequence.h"
    7571#include "MStatusArray.h"
    76 #include "MGeomCamMagic.h"
    7772#include "MBadPixelsCam.h"
     73#include "MHEffectiveOnTime.h"
    7874
    7975using namespace std;
     
    104100    if (!hsparks)
    105101    {
    106         cout << "WARNING - Reading of Sparks failed." << endl;
     102        cout << "ERROR - Reading of Sparks failed." << endl;
    107103        return 2;
    108104    }
     
    111107    if (!hcog)
    112108    {
    113         cout << "WARNING - Reading of MHHillas failed." << endl;
     109        cout << "ERROR - Reading of MHHillas failed." << endl;
    114110        return 2;
    115111    }
     
    118114    if (!hmuon)
    119115    {
    120         cout << "WARNING - Reading of MHMuon failed." << endl;
     116        cout << "ERROR - Reading of MHMuon failed." << endl;
    121117        return 2;
    122118    }
     
    132128        }
    133129
    134     Double_t inhom = TMath::RMS(6, val)*6/hcog->GetEntries()*100;
    135     inhom = TMath::Nint(inhom*10)/10.;
     130    Float_t inhom = TMath::RMS(6, val)*6/hcog->GetEntries()*100;
    136131    TString inhomogen = Form("%5.1f", inhom);
    137132
    138     Float_t mw    = hmuon->GetMeanWidth();
    139     Float_t psf   = 70.205*mw - 28.055;
    140     TString PSF = Form("%5.1f", psf<0?0:psf);
     133    Float_t mw  = hmuon->GetMeanWidth();
     134    Float_t psf = 70.205*mw - 28.055;
     135    TString PSF = Form("%5.1f", (psf<0?0:psf));
    141136    Int_t   num = (int)hmuon->GetEntries();
    142137
     
    147142    if (!h)
    148143    {
    149         cout << "WARNING - Reading of Islands failed." << endl;
     144        cout << "ERROR - Reading of Islands failed." << endl;
    150145        return 2;
    151146    }
     
    154149
    155150    h = (TH1*)arr.FindObjectInCanvas("EffOnTheta", "TH1D", "EffOnTime");
     151
     152    Float_t effon = h ? h->Integral() : -1;
     153
     154    h = (TH1*)arr.FindObjectInCanvas("Cleaned;avg", "TH1D", "Cleaned");
    156155    if (!h)
    157156    {
    158         cout << "WARNING - Reading of EffOnTheta failed." << endl;
    159         return 2;
    160     }
    161 
    162     Float_t effon = h->Integral();
     157        cout << "ERROR - Reading of Cleaned;avg failed." << endl;
     158        return 2;
     159    }
     160
     161    if (effon<0)
     162        effon = h->GetEntries()/100;
     163
    163164    Float_t mrate  = num/effon;
    164165    TString muonrate = Form("%6.2f", mrate<0?0:mrate);
    165     Int_t effontime = TMath::Nint(effon);
    166 
    167     h = (TH1*)arr.FindObjectInCanvas("ProjDeltaT", "TH1D", "EffOnTime");
    168     if (!h)
    169     {
    170         cout << "WARNING - Reading of ProjDeltaT failed." << endl;
    171         return 2;
    172     }
     166    TString effontime = Form("%.1f", effon);
    173167
    174168    Int_t numsparks = (int)hsparks->GetEntries();
    175169    Int_t numevents = (int)h->GetEntries() - numsparks;
    176     Int_t datarate  = (int)(numevents/effon);
     170    Int_t datarate  = TMath::Nint(numevents/effon);
    177171
    178172    TString sparkrate = Form("%5.2f", numsparks/effon);
     
    181175        sparkrate="0.00";
    182176
     177    MHEffectiveOnTime *ontm = (MHEffectiveOnTime*)arr.FindObjectInCanvas("MHEffectiveOnTime", "MHEffectiveOnTime", "EffOnTime");
     178    TString totontime = ontm ? Form("%d", TMath::Nint(ontm->GetTotalTime())) : "NULL";
     179    TString relontime = ontm ? Form("%.2f", effon/ontm->GetTotalTime()*100) : "NULL";
     180
    183181    TGraph *g = (TGraph*)arr.FindObjectInCanvas("Humidity", "TGraph", "MHWeather");
    184     if (!g)
    185     {
    186         cout << "WARNING - Reading of Humidity failed." << endl;
    187         return 2;
    188     }
     182
    189183    TString maxhum = CheckGraph(g) ? Form("%5.1f", TMath::MaxElement(g->GetN(), g->GetY())) : "NULL";
    190184    TString avghum = CheckGraph(g) ? Form("%5.1f", g->GetMean(2)) : "NULL";
    191185
    192186    g = (TGraph*)arr.FindObjectInCanvas("Temperature", "TGraph", "MHWeather");
    193     if (!g)
    194     {
    195         cout << "WARNING - Reading of Temperature failed." << endl;
    196         return 2;
    197     }
     187
    198188    TString avgtemp = CheckGraph(g) ? Form("%5.1f", g->GetMean(2)) : "NULL";
    199189
    200190    g = (TGraph*)arr.FindObjectInCanvas("WindSpeed", "TGraph", "MHWeather");
    201     if (!g)
    202     {
    203         cout << "WARNING - Reading of WindSpeed failed." << endl;
    204         return 2;
    205     }
     191
    206192    TString avgwind = CheckGraph(g) ? Form("%5.1f", g->GetMean(2)) : "NULL";
    207193
    208194    g = (TGraph*)arr.FindObjectInCanvas("Cloudiness", "TGraph", "MHWeather");
    209     if (!g)
    210         cout << "WARNING - Reading of Cloudiness failed." << endl;
    211 
     195    //if (!g)
     196    //    cout << "WARNING - Reading of Cloudiness failed." << endl;
    212197    TString avgclouds = CheckGraph(g) ? Form("%5.1f", g->GetMean(2)) : "NULL";
    213198    TString rmsclouds = CheckGraph(g) ? Form("%5.1f", g->GetRMS(2))  : "NULL";
    214199
    215200    g = (TGraph*)arr.FindObjectInCanvas("TempSky", "TGraph", "MHWeather");
    216     if (!g)
    217         cout << "WARNING - Reading of TempSky failed." << endl;
     201    //if (!g)
     202    //    cout << "WARNING - Reading of TempSky failed." << endl;
    218203    TString avgsky = CheckGraph(g) ? Form("%5.1f", g->GetMean(2)+200) : "NULL";
    219204
    220205
    221206    g = (TGraph*)arr.FindObjectInCanvas("NumStars", "TGraph", "MHPointing");
    222     if (!g)
    223         cout << "WARNING - Reading of NumStars failed." << endl;
    224 
     207    //if (!g)
     208    //    cout << "WARNING - Reading of NumStars failed." << endl;
    225209    TString numstarsmed = CheckGraph(g) ? Form("%5.1f", TMath::Median(g->GetN(), g->GetY())) : "NULL";
    226210    TString numstarsrms = CheckGraph(g) ? Form("%5.1f", g->GetRMS(2)) : "NULL";
    227211
    228212    g = (TGraph*)arr.FindObjectInCanvas("NumStarsCor", "TGraph", "MHPointing");
    229     if (!g)
    230         cout << "WARNING - Reading of NumStarsCor failed." << endl;
    231 
     213    //if (!g)
     214    //    cout << "WARNING - Reading of NumStarsCor failed." << endl;
    232215    TString numcorsmed = CheckGraph(g) ? Form("%5.1f", TMath::Median(g->GetN(), g->GetY())) : "NULL";
    233216    TString numcorsrms = CheckGraph(g) ? Form("%5.1f", g->GetRMS(2)) : "NULL";
    234217
    235218    g = (TGraph*)arr.FindObjectInCanvas("Brightness", "TGraph", "MHPointing");
    236     if (!g)
    237         cout << "WARNING - Reading of SkyBrightness failed." << endl;
    238 
     219    //if (!g)
     220    //    cout << "WARNING - Reading of SkyBrightness failed." << endl;
    239221    TString skybrightnessmed = CheckGraph(g) ? Form("%5.1f", TMath::Median(g->GetN(), g->GetY())) : "NULL";
    240222    TString skybrightnessrms = CheckGraph(g) ? Form("%5.1f", g->GetRMS(2)) : "NULL";
    241223
    242     TString sequence = fname(TRegexp("star[0-9]+[.]root$"));
    243     if (sequence.IsNull())
    244     {
    245         cout << "WARNING - Could not determine sequence# from filename: " << fname << endl;
    246         return 2;
    247     }
    248 
    249     Int_t seq = atoi(sequence.Data()+5);
    250 
    251     cout << "Sequence #" << seq << endl;
     224    MSequence seq;
     225    if (seq.Read("sequence[0-9]{8}|MSequence")<=0)
     226    {
     227        cout << "ERROR - Could not find sequence in file: " << fname << endl;
     228        return 2;
     229    }
     230    if (!seq.IsValid())
     231    {
     232        cout << "ERROR - Sequence read from file inavlid: " << fname << endl;
     233        return 2;
     234    }
     235
     236    cout << "Sequence M" << seq.GetTelescope() << ":" << seq.GetSequence() << endl;
    252237    cout << "  Inhomogeneity            " << inhomogen << endl;
    253238    cout << "  PSF [mm]                 " << PSF       << endl;
     
    255240    cout << "  Ratio [%]                " << ratio     << endl;
    256241    cout << "  Muon Number              " << num       << endl;
    257     cout << "  EffOnTime [s]            " << effontime << endl;
     242    cout << "  Eff. OnTime [s]          " << effontime << endl;
     243    cout << "  Tot. OnTime [s]          " << totontime << endl;
     244    cout << "  Rel. OnTime [%]          " << relontime << endl;
    258245    cout << "  Muon Rate [Hz]           " << muonrate  << endl;
    259246    cout << "  # of Events (w/o sparks) " << numevents << endl;
     
    271258    cout << "  Skybrightness            " << skybrightnessmed << " +/- " << skybrightnessrms << endl;
    272259
    273     TString vars = Form(" fMeanNumberIslands=%s,"
     260    TString vars = Form(" fSequenceFirst=%d, "
     261                        " fTelescopeNumber=%d, "
     262                        " fMeanNumberIslands=%s,"
    274263                        " fRatio=%s,"
    275264                        " fMuonNumber=%d,"
    276                         " fEffOnTime=%d,"
     265                        " fEffOnTime=%s,"
     266                        " fTotOnTime=%s,"
    277267                        " fMuonRate=%s,"
    278268                        " fPSF=%s,"
     
    293283                        " fBrightnessRMS=%s,"
    294284                        " fInhomogeneity=%s ",
     285                        seq.GetSequence(), seq.GetTelescope(),
    295286                        islands.Data(), ratio.Data(),
    296                         num, effontime,
     287                        num, effontime.Data(), totontime.Data(),
    297288                        muonrate.Data(), PSF.Data(),
    298289                        datarate, sparkrate.Data(), maxhum.Data(),
     
    304295                        inhomogen.Data());
    305296
    306     return serv.InsertUpdate("Star", "fSequenceFirst", Form("%d", seq), vars);
     297    TString where = Form("fSequenceFirst=%d AND fTelescopeNumber=%d",
     298                         seq.GetSequence(), seq.GetTelescope());
     299
     300    return serv.InsertUpdate("Star", vars, where) ? 1 : 2;
    307301}
    308302
Note: See TracChangeset for help on using the changeset viewer.