Ignore:
Timestamp:
09/06/13 17:14:10 (11 years ago)
Author:
Daniela Dorner
Message:
added new plots, fixed bugs
File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/Mars/fact/analysis/lightcurve.C

    r16693 r17104  
    33#include <TH1.h>
    44#include <TH2.h>
     5#include <TF1.h>
    56#include <TGraph.h>
    67#include <TGraphErrors.h>
    7 
     8#include <TText.h>
    89#include <TFile.h>
    910#include <TSystem.h>
     
    3132
    3233
    33 int lightcurve(Int_t sourcekey=1, Int_t nightmin=0, Int_t nightmax=0, Int_t minutes=20, TString table="AnalysisResultsRunLP", TString outfile="lc")
     34int lightcurve(Int_t sourcekey=1, Int_t nightmin=0, Int_t nightmax=0, Int_t minutes=20, TString table="AnalysisResultsRunLP", TString outfile="lc", Bool_t dch=kTRUE)
    3435{
    3536
     
    5455        query+=Form(" AND fNight <=%d",nightmax);
    5556
    56     cout << "Q: " << query << endl;
     57    // datacheck
     58    TString datacheck=" ";
     59    //remove data with wrong settings
     60    datacheck+=" AND fNight>20120420 AND NOT fNight IN (20120406,20120410,20120503) AND";//data with different bias voltage
     61    datacheck+=" NOT fNight BETWEEN 20121206 AND 20130110"; // broken bias channel
     62    //datacheck+=" AND NOT (fNight=20120608 AND fRunId=65) "; // something went wrong with tracking?
     63    // 24.6. new coefficients
     64    TString zdparam=" pow(0.753833 * cos(Radians(fZenithDistanceMean)), 7.647435) * exp(-5.753686*pow(Radians(fZenithDistanceMean),2.089609))";
     65    TString thparam=" pow((if(isnull(fThresholdMinSet),fThresholdMedian,fThresholdMinSet)-329.4203),2) * (-0.0000002044803) ";
     66    TString param=" (fNumEvtsAfterBgCuts/5-fNumSigEvts)/fOnTimeAfterCuts - "+zdparam+" - "+thparam+" ";
     67    datacheck+=" AND -0.085 < ("+param+") ";
     68    datacheck+=" AND 0.25 > ("+param+") ";
     69
     70
     71    if (dch)
     72        query+=datacheck;
     73
     74    //cout << "Q: " << query << endl;
    5775
    5876    TSQLResult *res = serv.Query(query);
     
    6987    query+=Form(" WHERE fSourceKey=%d", sourcekey);
    7088    query+=Form(" AND fNight BETWEEN %s AND %s ", nightstart.Data(), nightstop.Data());
    71     //query+=" AND NOT ISNULL(fOnTime) ";//at the moment filled at ISDC
    7289    query+=" GROUP BY fNight ";
    7390    query+=" ORDER BY fNight ";
     
    8097        return 1;
    8198
    82     Int_t counter=0;
    83     Int_t counter2=0;
     99    //counter
     100    Int_t counter=0;//counter for graphs
     101    Int_t counter2=0;//counter for loop
     102
     103    //graphs and histograms
    84104    TGraphErrors excessrate;
    85105    TGraphErrors backgroundrate;
     
    87107    TGraphErrors significancerate;
    88108    TGraphErrors excratevsbgrate;
     109    TGraphErrors excvsbg;
    89110    TGraphErrors excvszd;
    90     TGraphErrors excvsbg;
    91111    TGraphErrors bgvszd;
     112    TGraphErrors excvscur;
     113    TGraphErrors bgvscur;
     114    TGraphErrors excvsth;
     115    TGraphErrors bgvsth;
     116    TGraphErrors zdvstime;
     117    TGraphErrors curvstime;
     118    TGraphErrors thvstime;
    92119    TH1F exc("exc","rates", 43, -12.5, 202.5);
    93120    TH1F bg("bg","rates", 43, -12.5, 202.5);
    94121
     122    //variables for calculations and graphs
    95123    Float_t significance;
    96124    TString excevts;
     
    98126    TString sigevts;
    99127    TString ontime;
    100     TString zd;
    101128    TString zd2;
    102129    TString zd3;
     130    TString cur;
     131    TString th;
    103132    Float_t excevtssum=0;
    104133    Float_t bgevtssum=0;
     
    109138    Float_t signifrate=0;
    110139    Float_t excerr=0;
    111     Float_t zdsum=0;
     140    Float_t bgerr=0;
    112141    Float_t zdmean=0;
     142    Float_t curmean=0;
     143    Float_t thmean=0;
     144    Float_t zddiff=0;
     145    Float_t curdiff=0;
     146    Float_t thdiff=0;
    113147    Float_t zdmin=0;
    114148    Float_t zdmax=0;
     149    Float_t curmin=0;
     150    Float_t curmax=0;
     151    Float_t thmin=0;
     152    Float_t thmax=0;
    115153    MTime start;
    116154    MTime stop;
    117     Double_t mjdstart;
    118     Double_t mjdstop;
    119     Double_t mjd;
     155    Double_t mjdstart=0;
     156    Double_t mjdstop=0;
     157    Double_t mjd=0;
     158    Double_t mjddiff=0;
     159
    120160    TSQLRow *row3=0;
    121161    while ((row3=res3->Next()))
    122162    {
    123163        cout << "NIGHT " << (*row3)[0] << endl;
    124         query =" SELECT IF(ISNULL(fOnTimeAfterCuts), IF(ISNULL(fOnTime), Time_to_sec(Timediff(fRunStop,fRunStart)), fOnTime), fOnTimeAfterCuts), ";
    125         query+=" fNumBgEvts, fNumSigEvts, fNumExcEvts, ";
    126         query+=" fRunStart, fRunStop, (fZenithDistanceMax-fZenithDistanceMin)/2, ";
    127         query+=" fZenithDistanceMax, fZenithDistanceMin FROM "+table;
     164        //query =" SELECT IF(ISNULL(fOnTimeAfterCuts), IF(ISNULL(fOnTime), Time_to_sec(Timediff(fRunStop,fRunStart)), fOnTime), fOnTimeAfterCuts), ";
     165        query =" SELECT fOnTimeAfterCuts, fNumBgEvts, fNumSigEvts, fNumExcEvts, ";
     166        query+=" fRunStart, fRunStop, ";
     167        query+=" fZenithDistanceMax, fZenithDistanceMin, ";
     168        query+=" fCurrentsMedMeanBeg, fThresholdMinSet FROM "+table;
    128169        query+=" LEFT JOIN RunInfo USING(fNight, fRunId) ";
    129170        query+=Form(" WHERE fSourceKey=%d", sourcekey);
    130171        query+=Form(" AND fNight= %s ", (*row3)[0]);
    131         //query+=" AND NOT ISNULL(fOnTime) ";//at the moment filled at isdc
     172        query+=" AND fOnTimeAfterCuts < 1000 "; //exclude runs with wrong/too high ontime
     173        query+=" AND NOT ISNULL(fNumExcEvts) ";// only where excess was extracted
     174
     175        if (dch)
     176            query+=datacheck;
     177
    132178        query+=" ORDER BY fRunId ";
    133179
     
    147193        {
    148194            counter2++;
    149             cout << "-----" << (*row2)[0] << " " << (*row2)[3] << endl;
    150195            ontime=(*row2)[0];
    151196            bgevts=(*row2)[1];
    152197            sigevts=(*row2)[2];
    153198            excevts=(*row2)[3];
    154             zd=(*row2)[6];
    155             zd2=(*row2)[7];
    156             zd3=(*row2)[8];
    157             start.SetSqlDateTime((*row2)[4]);
    158             stop.SetSqlDateTime((*row2)[5]);
     199            zd2=(*row2)[6];//zdmin
     200            zd3=(*row2)[7];//zdmax
     201            cur=(*row2)[8];//currents
     202            th=(*row2)[9];//threshold
    159203            if (counter2==1)
    160204            {
    161                 mjdstart=start.GetMjd();
    162                 cout << "mjdstart: " << (*row2)[4] << endl;
     205                start.SetSqlDateTime((*row2)[4]);
    163206                zdmin=zd3.Atof();
    164207                zdmax=zd2.Atof();
     208                curmin=cur.Atof();
     209                curmax=cur.Atof();
     210                thmin=th.Atof();
     211                thmax=th.Atof();
    165212            }
    166213
    167             cout << "# " << counter2 << " " << (*row2)[0] << " " << (*row2)[1] << " " << (*row2)[2] << " " << (*row2)[3] << endl;
    168 
    169             if (ontimesum+ontime.Atof()>minutes)
     214            if (ontimesum+ontime.Atof()>minutes && minutes>0)
    170215            {
    171                 cout << "reached limit" << endl;
    172                 significance=MMath::SignificanceLiMa(sigevtssum, bgevtssum, 0.2);
    173                 cout << "  significance: " << significance << endl;
    174                 cout << "  excess: " << excevtssum << " evts" << endl;
    175                 cout << "  bg: " << bgevtssum << " evts" << endl;
    176                 cout << "  ontime: " << ontimesum << " s " << endl;
    177                 cout << "  excessrate: " << excevtssum/ontimesum*3600 << " evts/h" << endl;
    178                 cout << "  bgrate: " << bgevtssum/ontimesum*3600 << " evts/h" << endl;
    179                 signifrate=significance/sqrt(ontimesum*3600);
    180                 bgrate=bgevtssum/ontimesum*3600;
    181                 excrate=excevtssum/ontimesum*3600;
    182                 excerr = MMath::ErrorExc(significance, bgevtssum, 0.2)/ontimesum*3600.;
    183                 //zdmean=zdsum/counter2;
    184                 zdmean=zdmin+(zdmax-zdmin)/2;
    185                 mjdstop=stop.GetMjd();
    186                 mjd=mjdstart+(mjdstop-mjdstart)/2;
    187                 cout << "  mjd: " << mjd <<  " (" << mjdstart << " - " << mjdstop << ") " << endl;
    188                 if (excrate>300)
    189                     cout << "==>" << (*row2)[0] << " " << (*row2)[1] << " " << (*row2)[2]
    190                         << " " << (*row2)[3] << " " << (*row2)[4] << " " << (*row2)[5]
    191                         << " " << (*row2)[6] << " " << (*row2)[7] << " " << (*row2)[8]
    192                         << endl;
    193 
     216                //calculate values
     217                significance = MMath::SignificanceLiMaSigned(sigevtssum, bgevtssum*5, 0.2);
     218                signifrate = significance/sqrt(ontimesum/3600);
     219                bgrate = bgevtssum/ontimesum*3600;
     220                excrate = excevtssum/ontimesum*3600;
     221                excerr = MMath::ErrorExc(sigevtssum, bgevtssum*5, 0.2)/ontimesum*3600.;
     222                bgerr = sqrt(bgevtssum)/ontimesum*3600;
     223                zdmean = zdmin+(zdmax-zdmin)/2;
     224                zddiff = (zdmax-zdmin)/2;
     225                curmean = curmin+(curmax-curmin)/2;
     226                curdiff = (curmax-curmin)/2;
     227                thmean = thmin+(thmax-thmin)/2;
     228                thdiff = (thmax-thmin)/2;
     229                mjdstart = start.GetMjd();
     230                mjdstop = stop.GetMjd();
     231                mjd = mjdstart+(mjdstop-mjdstart)/2.;
     232                mjddiff = ontimesum/3600./24/2;
     233
     234                //fill histograms and graphs
     235                exc.Fill(excrate);
     236                bg.Fill(bgrate);
     237                excessrate.SetPoint(counter, mjd, excrate);
     238                excessrate.SetPointError(counter, mjddiff, excerr);
     239                backgroundrate.SetPoint(counter, mjd, bgrate);
     240                backgroundrate.SetPointError(counter, mjddiff, bgerr);
     241                excvsbg.SetPoint(counter, bgrate, excrate);
     242                excvsbg.SetPointError(counter, bgerr, excerr);
     243                excvszd.SetPoint(counter, zdmean, excrate);
     244                excvszd.SetPointError(counter, zddiff, excerr);
     245                bgvszd.SetPoint(counter, zdmean, bgrate);
     246                bgvszd.SetPointError(counter, zddiff, bgerr);
     247                excvscur.SetPoint(counter, curmean, excrate);
     248                excvscur.SetPointError(counter, curdiff, excerr);
     249                bgvscur.SetPoint(counter, curmean, bgrate);
     250                bgvscur.SetPointError(counter, curdiff, bgerr);
     251                excvsth.SetPoint(counter, thmean, excrate);
     252                excvsth.SetPointError(counter, thdiff, excerr);
     253                bgvsth.SetPoint(counter, thmean, bgrate);
     254                bgvsth.SetPointError(counter, thdiff, bgerr);
     255                signif.SetPoint(counter, mjd, significance);
     256                signif.SetPointError(counter, mjddiff, 0);
     257                significancerate.SetPoint(counter, mjd, signifrate);
     258                significancerate.SetPointError(counter, mjddiff, 0);
     259                zdvstime.SetPoint(counter, mjd, zdmean);
     260                zdvstime.SetPointError(counter, mjddiff, zddiff);
     261                curvstime.SetPoint(counter, mjd, curmean);
     262                curvstime.SetPointError(counter, mjddiff, curdiff);
     263                thvstime.SetPoint(counter, mjd, thmean);
     264                thvstime.SetPointError(counter, mjddiff, thdiff);
     265
     266                //set couter for graphs
     267                counter++;
     268                //reset counter for calculation
     269                counter2=0;
     270                //reset variables
     271                start.SetSqlDateTime((*row2)[4]);
    194272                excevtssum=0;
    195273                bgevtssum=0;
    196274                sigevtssum=0;
    197275                ontimesum=0;
    198                 zdsum=0;
    199                 exc.Fill(excrate);
    200                 bg.Fill(bgrate);
    201                 excessrate.SetPoint(counter, mjd, excrate);
    202                 excessrate.SetPointError(counter, ontimesum/3600./24/2, excerr);
    203                 backgroundrate.SetPoint(counter, mjd, bgrate);
    204                 backgroundrate.SetPointError(counter, ontimesum/3600./24/2, sqrt(bgevtssum)/ontimesum*3600);
    205                 excvszd.SetPoint(counter, zdmean, excrate);
    206                 excvszd.SetPointError(counter, (zdmax-zdmin)/2, excerr);
    207                 excvsbg.SetPoint(counter, bgrate, excrate);
    208                 excvsbg.SetPointError(counter, sqrt(bgevtssum)/ontimesum*3600, excerr);
    209                 bgvszd.SetPoint(counter, zdmean, bgrate);
    210                 bgvszd.SetPointError(counter, (zdmax-zdmin)/2, sqrt(bgevtssum)/ontimesum*3600);
    211                 signif.SetPoint(counter, mjd, significance);
    212                 signif.SetPointError(counter, ontimesum/3600./24/2, 0);
    213                 significancerate.SetPoint(counter, mjd, signifrate);
    214                 significancerate.SetPointError(counter, ontimesum/3600./24/2, 0);
    215                 counter++;
    216                 counter2=0;
    217276            }
     277            //set stop time
     278            stop.SetSqlDateTime((*row2)[5]);
     279            //add up variables
    218280            ontimesum+=ontime.Atof();
    219281            excevtssum+=excevts.Atof();
    220282            bgevtssum+=bgevts.Atof();
    221283            sigevtssum+=sigevts.Atof();
    222             zdsum+=zd.Atof();
     284
     285            //update zdmin
    223286            if (zdmin>zd3.Atof())
    224287                zdmin=zd3.Atof();
     288            //update zdmax
    225289            if (zdmax<zd2.Atof())
    226290                zdmax=zd2.Atof();
    227             //cout << "--> on " << ontimesum << " exc " << excevtssum << " bg " << bgevtssum << " sig " << sigevtssum << endl;
     291
     292            //update curmin
     293            if (curmin>cur.Atof())
     294                curmin=cur.Atof();
     295            //update curmax
     296            if (curmax<cur.Atof())
     297                curmax=cur.Atof();
     298
     299            //update thmin
     300            if (thmin>th.Atof())
     301                thmin=th.Atof();
     302            //update thmax
     303            if (thmax<th.Atof())
     304                thmax=th.Atof();
    228305
    229306        }
    230         cout << "reached last run" << endl;
     307        //cout << "reached last run" << endl;
    231308        // if ontime is larger than 90% of the timebin width, the last point is filled
    232         if (ontimesum>(minutes-0.1*minutes))
     309        if (ontimesum>(minutes-0.1*minutes) || minutes<0)
    233310        {
    234             cout << "ontime > " << minutes-0.1*minutes << endl;
    235             significance=MMath::SignificanceLiMa(sigevtssum, bgevtssum, 0.2);
    236             cout << "  significance: " << significance << endl;
    237             cout << "  excess: " << excevtssum << " evts" << endl;
    238             cout << "  bg: " << bgevtssum << " evts" << endl;
    239             cout << "  ontime: " << ontimesum << " s " << endl;
    240             cout << "  excessrate: " << excevtssum/ontimesum*3600 << " evts/h" << endl;
    241             cout << "  bgrate: " << bgevtssum/ontimesum*3600 << " evts/h" << endl;
    242             signifrate=significance/sqrt(ontimesum*3600);
    243             bgrate=bgevtssum/ontimesum*3600;
    244             excrate=excevtssum/ontimesum*3600;
    245             excerr = MMath::ErrorExc(significance, bgevtssum, 0.2)/ontimesum*3600.;
    246             zdmean=zdmin+(zdmax-zdmin)/2;
    247             mjdstop=stop.GetMjd();
    248             mjd=mjdstart+(mjdstop-mjdstart)/2;
    249             cout << "  mjd: " << mjd <<  " (" << mjdstart << " - " << mjdstop << ") " << endl;
    250 
    251             exc.Fill(excrate);
    252             bg.Fill(bgrate);
    253             excessrate.SetPoint(counter, mjd, excrate);
    254             excessrate.SetPointError(counter, ontimesum/3600./24/2, excerr);
    255             backgroundrate.SetPoint(counter, mjd, bgrate);
    256             backgroundrate.SetPointError(counter, ontimesum/3600./24/2, sqrt(bgevtssum)/ontimesum*3600);
    257             excvszd.SetPoint(counter, zdmean, excrate);
    258             excvszd.SetPointError(counter, (zdmax-zdmin)/2, excerr);
    259             excvsbg.SetPoint(counter, bgrate, excrate);
    260             excvsbg.SetPointError(counter, sqrt(bgevtssum)/ontimesum*3600, excerr);
    261             bgvszd.SetPoint(counter, zdmean, bgrate);
    262             bgvszd.SetPointError(counter, (zdmax-zdmin)/2, sqrt(bgevtssum)/ontimesum*3600);
    263             signif.SetPoint(counter, mjd, significance);
    264             signif.SetPointError(counter, ontimesum/3600./24/2, 0);
    265             significancerate.SetPoint(counter, mjd, signifrate);
    266             significancerate.SetPointError(counter, ontimesum/3600./24/2, 0);
     311            if (minutes<0 && ontimesum>20*60 && bgevtssum!=0)
     312            {
     313                //calculate values
     314                significance = MMath::SignificanceLiMaSigned(sigevtssum, bgevtssum*5, 0.2);
     315                signifrate = significance/sqrt(ontimesum/3600);
     316                bgrate = bgevtssum/ontimesum*3600;
     317                excrate = excevtssum/ontimesum*3600;
     318                excerr = MMath::ErrorExc(sigevtssum, bgevtssum*5, 0.2)/ontimesum*3600.;
     319                bgerr = sqrt(bgevtssum)/ontimesum*3600;
     320                zdmean = zdmin+(zdmax-zdmin)/2;
     321                zddiff = (zdmax-zdmin)/2;
     322                curmean = curmin+(curmax-curmin)/2;
     323                curdiff = (curmax-curmin)/2;
     324                thmean = thmin+(thmax-thmin)/2;
     325                thdiff = (thmax-thmin)/2;
     326                mjdstart = start.GetMjd();
     327                mjdstop = stop.GetMjd();
     328                mjd = mjdstart+(mjdstop-mjdstart)/2.;
     329                mjddiff = ontimesum/3600./24/2;
     330
     331                //fill histograms and graphs
     332                exc.Fill(excrate);
     333                bg.Fill(bgrate);
     334                excessrate.SetPoint(counter, mjd, excrate);
     335                excessrate.SetPointError(counter, mjddiff, excerr);
     336                backgroundrate.SetPoint(counter, mjd, bgrate);
     337                backgroundrate.SetPointError(counter, mjddiff, bgerr);
     338                excvsbg.SetPoint(counter, bgrate, excrate);
     339                excvsbg.SetPointError(counter, bgerr, excerr);
     340                excvszd.SetPoint(counter, zdmean, excrate);
     341                excvszd.SetPointError(counter, zddiff, excerr);
     342                bgvszd.SetPoint(counter, zdmean, bgrate);
     343                bgvszd.SetPointError(counter, zddiff, bgerr);
     344                excvscur.SetPoint(counter, curmean, excrate);
     345                excvscur.SetPointError(counter, curdiff, excerr);
     346                bgvscur.SetPoint(counter, curmean, bgrate);
     347                bgvscur.SetPointError(counter, curdiff, bgerr);
     348                excvsth.SetPoint(counter, thmean, excrate);
     349                excvsth.SetPointError(counter, thdiff, excerr);
     350                bgvsth.SetPoint(counter, thmean, bgrate);
     351                bgvsth.SetPointError(counter, thdiff, bgerr);
     352                signif.SetPoint(counter, mjd, significance);
     353                signif.SetPointError(counter, mjddiff, 0);
     354                significancerate.SetPoint(counter, mjd, signifrate);
     355                significancerate.SetPointError(counter, mjddiff, 0);
     356                zdvstime.SetPoint(counter, mjd, zdmean);
     357                zdvstime.SetPointError(counter, mjddiff, zddiff);
     358                curvstime.SetPoint(counter, mjd, curmean);
     359                curvstime.SetPointError(counter, mjddiff, curdiff);
     360                thvstime.SetPoint(counter, mjd, thmean);
     361                thvstime.SetPointError(counter, mjddiff, thdiff);
     362
     363                //set counter for graphs
     364                counter++;
     365
     366                //reset variables
     367                excevtssum=0;
     368                bgevtssum=0;
     369                sigevtssum=0;
     370                ontimesum=0;
     371            }
     372
     373            //reset for calculations
     374            counter2=0;
    267375        }
    268376        delete res2;
     
    275383    MStatusDisplay *d = new MStatusDisplay;
    276384
     385//    if (dch)
     386//        backgroundrate.SetTitle(Form("Rates vs MJD (dch: %s)", limit.Data()));
     387//    else
     388
     389
     390    Double_t x;
     391    Double_t y;
     392    Double_t min;
     393    Double_t max;
     394
     395    TText txt;
     396    txt.SetTextColor(kGray+2);
     397    txt.SetTextSize(0.07);
     398    TString text="FACT Preliminary";
     399
     400
     401
     402    gROOT->SetSelectedPad(0);
    277403    TCanvas &c1 = d->AddTab("Rates vs MJD", "Rates vs MJD");
    278404    gPad->SetGridy();
    279     excessrate.SetTitle("Rates vs MJD");
    280     excessrate.SetMarkerStyle(7);
    281     excessrate.SetMarkerSize(2);
    282     excessrate.GetYaxis()->SetTitle("evts/h");
    283     excessrate.GetXaxis()->SetTitle("MJD");
    284     excessrate.GetXaxis()->CenterTitle();
    285     excessrate.GetYaxis()->SetRangeUser(-50,400);
    286     excessrate.DrawClone("AP");
    287 
    288     backgroundrate.SetMarkerStyle(7);
    289     backgroundrate.SetMarkerSize(2);
     405
     406    excessrate.GetPoint(1,x,y);
     407    max = excessrate.GetHistogram()->GetMaximum();
     408    min = excessrate.GetHistogram()->GetMinimum();
     409
     410    backgroundrate.SetTitle("Rates vs MJD");
     411    backgroundrate.SetMarkerStyle(8);
     412    backgroundrate.SetMarkerSize(0.8);
     413    backgroundrate.SetLineWidth(2);
    290414    backgroundrate.SetMarkerColor(kBlue);
    291415    backgroundrate.SetLineColor(kBlue);
    292     backgroundrate.DrawClone("Psame");
    293 
    294     TCanvas &c2 = d->AddTab("Excess Rate vs MJD", "Excess Rate vs MJD");
     416    backgroundrate.GetYaxis()->SetTitle("evts/h");
     417    backgroundrate.GetXaxis()->SetTitle("MJD");
     418    backgroundrate.GetXaxis()->CenterTitle();
     419    backgroundrate.GetYaxis()->SetRangeUser(min-min*0.1,max*1.1);
     420    backgroundrate.DrawClone("AP");
     421
     422    excessrate.SetMarkerStyle(8);
     423    excessrate.SetMarkerSize(0.8);
     424    excessrate.SetLineWidth(2);
     425    excessrate.DrawClone("Psame");
     426
     427    txt.DrawText(x, max, text);
     428
     429
     430
     431    gROOT->SetSelectedPad(0);
     432    TCanvas &c2 = d->AddTab("Excess vs MJD", "Excess vs MJD");
    295433    gPad->SetGridy();
    296434    excessrate.SetTitle("Excess Rate vs MJD");
    297435    excessrate.SetMarkerStyle(7);
    298436    excessrate.SetMarkerSize(2);
    299     excessrate.GetYaxis()->SetTitle("exc evts/h");
     437    excessrate.GetYaxis()->SetTitle("excess evts/h");
    300438    excessrate.GetXaxis()->SetTitle("MJD");
    301439    excessrate.GetXaxis()->CenterTitle();
     440    excessrate.GetYaxis()->SetRangeUser(min-min*0.1,max*1.1);
    302441    excessrate.DrawClone("AP");
    303 
     442    txt.DrawText(x, max, text);
     443
     444
     445
     446    gROOT->SetSelectedPad(0);
     447    TCanvas &c4 = d->AddTab("Exc vs Bg", "Exc vs Bg");
     448
     449    backgroundrate.GetPoint(1,x,y);
     450    max = excvsbg.GetHistogram()->GetMaximum();
     451    min = excvsbg.GetHistogram()->GetMinimum();
     452
     453    excvsbg.SetTitle("Excess Rate vs Background Rate");
     454    excvsbg.SetMarkerStyle(7);
     455    excvsbg.SetMarkerSize(2);
     456    excvsbg.GetYaxis()->SetTitle("excess evts/h");
     457    excvsbg.GetXaxis()->SetTitle("background evts/h");
     458    excvsbg.GetXaxis()->CenterTitle();
     459    excvsbg.GetYaxis()->SetRangeUser(min-min*0.1,max*1.1);
     460    excvsbg.DrawClone("AP");
     461    txt.DrawText(excvsbg.GetMean(1), max, text);
     462
     463
     464
     465    gROOT->SetSelectedPad(0);
    304466    TCanvas &c3 = d->AddTab("Exc vs Zd", "Exc vs Zd");
     467
     468    excvszd.GetPoint(1,x,y);
     469    max = excvszd.GetHistogram()->GetMaximum();
     470    min = excvszd.GetHistogram()->GetMinimum();
     471
    305472    excvszd.SetTitle("Excess Rate vs Zd");
    306473    excvszd.SetMarkerStyle(7);
    307474    excvszd.SetMarkerSize(2);
    308     excvszd.GetYaxis()->SetTitle("exc evts/h");
    309     excvszd.GetXaxis()->SetTitle("zd");
     475    excvszd.GetYaxis()->SetTitle("excess evts/h");
     476    excvszd.GetXaxis()->SetTitle("deg");
    310477    excvszd.GetXaxis()->CenterTitle();
     478    excvszd.GetYaxis()->SetRangeUser(min-min*0.1,max*1.1);
    311479    excvszd.DrawClone("AP");
    312 
    313     TCanvas &c4 = d->AddTab("Exc vs Bg", "Exc vs Bg");
    314     excvsbg.SetTitle("Excess Rate vs Background Rate");
    315     excvsbg.SetMarkerStyle(7);
    316     excvsbg.SetMarkerSize(2);
    317     excvsbg.GetYaxis()->SetTitle("exc evts/h");
    318     excvsbg.GetXaxis()->SetTitle("bg evts/h");
    319     excvsbg.GetXaxis()->CenterTitle();
    320     excvsbg.DrawClone("AP");
    321 
     480    txt.DrawText(x, max, text);
     481
     482
     483
     484    gROOT->SetSelectedPad(0);
    322485    TCanvas &c5 = d->AddTab("Bg vs Zd", "Bg vs Zd");
     486
     487    zdvstime.GetPoint(1,x,y);
     488    max = bgvszd.GetHistogram()->GetMaximum();
     489    min = bgvszd.GetHistogram()->GetMinimum();
     490
    323491    bgvszd.SetTitle("Background Rate vs Zd");
    324492    bgvszd.SetMarkerStyle(7);
    325493    bgvszd.SetMarkerSize(2);
    326     bgvszd.GetYaxis()->SetTitle("bg evts/h");
    327     bgvszd.GetXaxis()->SetTitle("zd");
     494    bgvszd.GetYaxis()->SetTitle("background evts/h");
     495    bgvszd.GetXaxis()->SetTitle("deg");
    328496    bgvszd.GetXaxis()->CenterTitle();
     497    bgvszd.GetYaxis()->SetRangeUser(min-min*0.1,max*1.1);
    329498    bgvszd.DrawClone("AP");
    330 
     499    txt.DrawText(y, max, text);
     500
     501
     502
     503    gROOT->SetSelectedPad(0);
    331504    TCanvas &c6 = d->AddTab("Signifrate vs MJD", "Signifrate vs MJD");
    332505    gPad->SetGridy();
     506
     507    significancerate.GetPoint(1,x,y);
     508    max = significancerate.GetHistogram()->GetMaximum();
     509    min = significancerate.GetHistogram()->GetMinimum();
     510
    333511    significancerate.SetTitle("Significance Rate vs MJD");
    334512    significancerate.SetMarkerStyle(7);
     
    337515    significancerate.GetXaxis()->SetTitle("MJD");
    338516    significancerate.GetXaxis()->CenterTitle();
     517    significancerate.GetYaxis()->SetRangeUser(0,max*1.1);
    339518    significancerate.DrawClone("AP");
    340 
    341     TCanvas &c7 = d->AddTab("Significance vs MJD", "Significance vs MJD");
     519    txt.DrawText(x, max, text);
     520
     521
     522
     523    gROOT->SetSelectedPad(0);
     524    TCanvas &c7 = d->AddTab("Signif vs MJD", "Signif vs MJD");
     525
     526    signif.GetPoint(1,x,y);
     527    max = signif.GetHistogram()->GetMaximum();
     528    min = signif.GetHistogram()->GetMinimum();
     529
    342530    signif.SetTitle("Significance vs MJD");
    343531    signif.SetMarkerStyle(7);
     
    346534    signif.GetXaxis()->SetTitle("MJD");
    347535    signif.GetXaxis()->CenterTitle();
     536    signif.GetYaxis()->SetRangeUser(0,max*1.1);
    348537    signif.DrawClone("AP");
    349 
     538    txt.DrawText(x, max, text);
     539
     540
     541
     542    gROOT->SetSelectedPad(0);
    350543    TCanvas &c8 = d->AddTab("Rate Hist", "Rate Hist");
     544
     545    max = bg.GetMaximum()*1.1;
     546    min = bg.GetMinimum();
     547
    351548    bg.SetLineColor(kBlue);
     549    bg.GetYaxis()->SetRangeUser(0,max*1.1);
     550    bg.GetXaxis()->SetTitle("evts/h");
    352551    bg.DrawCopy("hist");
    353552    exc.DrawCopy("histsame");
     553    txt.DrawText(min, max, text);
     554
     555
     556
     557    gROOT->SetSelectedPad(0);
     558    TCanvas &c9 = d->AddTab("Zd vs Time", "Zd vs Time");
     559    gPad->SetGridy();
     560
     561    zdvstime.GetPoint(1,x,y);
     562    max = zdvstime.GetHistogram()->GetMaximum();
     563    min = zdvstime.GetHistogram()->GetMinimum();
     564
     565    zdvstime.SetTitle("Zd vs MJD");
     566    zdvstime.SetMarkerStyle(7);
     567    zdvstime.SetMarkerSize(2);
     568    zdvstime.GetYaxis()->SetTitle("deg");
     569    zdvstime.GetXaxis()->SetTitle("MJD");
     570    zdvstime.GetXaxis()->CenterTitle();
     571    zdvstime.GetYaxis()->SetRangeUser(min-min*0.1,max*1.1);
     572    zdvstime.DrawClone("AP");
     573    txt.DrawText(x, max, text);
     574
     575
     576
     577    gROOT->SetSelectedPad(0);
     578    TCanvas &c10 = d->AddTab("Cur vs Time", "Cur vs Time");
     579    gPad->SetGridy();
     580
     581    curvstime.GetPoint(1,x,y);
     582    max = curvstime.GetHistogram()->GetMaximum();
     583    min = curvstime.GetHistogram()->GetMinimum();
     584
     585    curvstime.SetTitle("Currents vs MJD");
     586    curvstime.SetMarkerStyle(7);
     587    curvstime.SetMarkerSize(2);
     588    curvstime.GetYaxis()->SetTitle("#muA");
     589    curvstime.GetXaxis()->SetTitle("MJD");
     590    curvstime.GetXaxis()->CenterTitle();
     591    curvstime.GetYaxis()->SetRangeUser(min-min*0.1,max*1.1);
     592    curvstime.DrawClone("AP");
     593    txt.DrawText(x, max, text);
     594
     595
     596
     597    gROOT->SetSelectedPad(0);
     598    TCanvas &c11 = d->AddTab("Th vs Time", "Th vs Time");
     599    gPad->SetGridy();
     600
     601    thvstime.GetPoint(1,x,y);
     602    max = thvstime.GetHistogram()->GetMaximum();
     603    min = thvstime.GetHistogram()->GetMinimum();
     604
     605    thvstime.SetTitle("Threshold vs MJD");
     606    thvstime.SetMarkerStyle(7);
     607    thvstime.SetMarkerSize(2);
     608    thvstime.GetYaxis()->SetTitle("DAC counts");
     609    thvstime.GetXaxis()->SetTitle("MJD");
     610    thvstime.GetXaxis()->CenterTitle();
     611    thvstime.GetYaxis()->SetRangeUser(min-min*0.1,max*1.1);
     612    thvstime.DrawClone("AP");
     613    txt.DrawText(x, max, text);
     614
     615
     616
     617    gROOT->SetSelectedPad(0);
     618    TCanvas &c12 = d->AddTab("Exc vs Cur", "Exc vs Cur");
     619
     620    excvscur.GetPoint(1,x,y);
     621    max = excvscur.GetHistogram()->GetMaximum();
     622    min = excvscur.GetHistogram()->GetMinimum();
     623
     624    excvscur.SetTitle("Excess Rate vs Currents");
     625    excvscur.SetMarkerStyle(7);
     626    excvscur.SetMarkerSize(2);
     627    excvscur.GetYaxis()->SetTitle("excess evts/h");
     628    excvscur.GetXaxis()->SetTitle("#muA");
     629    excvscur.GetXaxis()->CenterTitle();
     630    excvscur.GetYaxis()->SetRangeUser(min-min*0.1,max*1.1);
     631    excvscur.DrawClone("AP");
     632    txt.DrawText(x, max, text);
     633
     634
     635
     636    gROOT->SetSelectedPad(0);
     637    TCanvas &c13 = d->AddTab("Bg vs Cur", "Bg vs Cur");
     638
     639    curvstime.GetPoint(1,x,y);
     640    max = bgvscur.GetHistogram()->GetMaximum();
     641    min = bgvscur.GetHistogram()->GetMinimum();
     642
     643    bgvscur.SetTitle("Background Rate vs Current");
     644    bgvscur.SetMarkerStyle(7);
     645    bgvscur.SetMarkerSize(2);
     646    bgvscur.GetYaxis()->SetTitle("background evts/h");
     647    bgvscur.GetXaxis()->SetTitle("#muA");
     648    bgvscur.GetXaxis()->CenterTitle();
     649    bgvscur.GetYaxis()->SetRangeUser(min-min*0.1,max*1.1);
     650    bgvscur.DrawClone("AP");
     651    txt.DrawText(y, max, text);
     652
     653
     654
     655    gROOT->SetSelectedPad(0);
     656    TCanvas &c14 = d->AddTab("Exc vs Th", "Exc vs Th");
     657
     658    excvsth.GetPoint(1,x,y);
     659    max = excvsth.GetHistogram()->GetMaximum();
     660    min = excvsth.GetHistogram()->GetMinimum();
     661
     662    excvsth.SetTitle("Excess Rate vs Threshold");
     663    excvsth.SetMarkerStyle(7);
     664    excvsth.SetMarkerSize(2);
     665    excvsth.GetYaxis()->SetTitle("excess evts/h");
     666    excvsth.GetXaxis()->SetTitle("DAC counts");
     667    excvsth.GetXaxis()->CenterTitle();
     668    excvsth.GetYaxis()->SetRangeUser(min-min*0.1,max*1.1);
     669    excvsth.DrawClone("AP");
     670    txt.DrawText(x, max, text);
     671
     672
     673
     674    gROOT->SetSelectedPad(0);
     675    TCanvas &c15 = d->AddTab("Bg vs Th", "Bg vs Th");
     676
     677    thvstime.GetPoint(1,x,y);
     678    max = bgvsth.GetHistogram()->GetMaximum();
     679    min = bgvsth.GetHistogram()->GetMinimum();
     680
     681    bgvsth.SetTitle("Background Rate vs Threshold");
     682    bgvsth.SetMarkerStyle(7);
     683    bgvsth.SetMarkerSize(2);
     684    bgvsth.GetYaxis()->SetTitle("background evts/h");
     685    bgvsth.GetXaxis()->SetTitle("DAC counts");
     686    bgvsth.GetXaxis()->CenterTitle();
     687    bgvsth.GetYaxis()->SetRangeUser(min-min*0.1,max*1.1);
     688    bgvsth.DrawClone("AP");
     689    txt.DrawText(y, max, text);
     690
     691
     692
    354693
    355694    d->SaveAs(outfile);
Note: See TracChangeset for help on using the changeset viewer.