Ignore:
Timestamp:
07/16/02 15:35:15 (22 years ago)
Author:
wittek
Message:
*** empty log message ***
File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/MagicSoft/Mars/mhist/MHAlphaEnergyTime.cc

    r1330 r1415  
    6868    fHist.SetTitle("3D-plot of alpha, E-est, time");
    6969    fHist.SetXTitle("\\alpha [\\circ]");
    70     fHist.SetYTitle("E_{est} [GeV]");
     70    fHist.SetYTitle("E-est [GeV]            ");
    7171    fHist.SetZTitle("time [s]");
    7272}
     
    8181   if (!fEnergy)
    8282   {
    83        *fLog << err << dbginf << "MEnergyEst not found... aborting." << endl;
     83       *fLog << err << dbginf << "MHAlphaEnergyTime : MEnergyEst not found... aborting." << endl;
    8484       return kFALSE;
    8585   }
     
    8888   if (!fTime)
    8989   {
    90        *fLog << err << dbginf << "MTime not found... aborting." << endl;
     90       *fLog << err << dbginf << "MHAlphaEnergyTime : MTime not found... aborting." << endl;
    9191       return kFALSE;
    9292   }
    9393
    9494   MBinning* binsenergy = (MBinning*)plist->FindObject("BinningE");
    95    MBinning* binsalpha  = (MBinning*)plist->FindObject("BinningAlpha");
     95   MBinning* binsalphaflux  = (MBinning*)plist->FindObject("BinningAlphaFlux");
    9696   MBinning* binstime   = (MBinning*)plist->FindObject("BinningTime");
    97    if (!binsenergy || !binsalpha || !binstime)
     97   if (!binsenergy || !binsalphaflux || !binstime)
    9898   {
    99        *fLog << err << dbginf << "At least one MBinning not found... aborting." << endl;
     99       *fLog << err << dbginf << "MHAlphaEnergyTime : At least one MBinning not found... aborting." << endl;
    100100       return kFALSE;     
    101101   }
    102102
    103    SetBinning(&fHist, binsalpha, binsenergy, binstime);
     103   SetBinning(&fHist, binsalphaflux, binsenergy, binstime);
    104104
    105105   fHist.Sumw2();
     
    116116    MHillasSrc &hil = *(MHillasSrc*)par;
    117117
    118     fHist.Fill(hil.GetAlpha(), fEnergy->GetEnergy(), 0.0001*fTime->GetTimeLo());
     118    fHist.Fill(fabs(hil.GetAlpha()), fEnergy->GetEnergy(), 0.0001*fTime->GetTimeLo());
    119119    return kTRUE;
    120120}
     
    147147
    148148    h->SetTitle("Distribution of E-est [GeV]");
    149     h->SetXTitle("E_{est} [GeV]");
     149    h->SetXTitle("E-est [GeV]            ");
    150150    h->SetYTitle("Counts");
    151151
     
    226226}
    227227
    228 // --------------------------------------------------------------------------
    229 //
    230 // Calculate the histogram as the difference of two histograms :
    231 //          fHist(gamma) = h1(source) - h2(antisource)
    232 //
    233 void MHAlphaEnergyTime::Subtract(const TH3D *h1, const TH3D *h2)
    234 {
    235   //    MH::SetBinning(&fHist, (TH1*)h1);
    236 
    237   //    fHist.Sumw2();
    238     fHist.Add((TH1*)h1, (TH1*)h2, 1, -1); // ROOT: FIXME!
    239 }
    240 
    241 // --------------------------------------------------------------------------
    242 //
    243 // Integrate fHist(gamma) in the alpha range (lo, up)
    244 //
    245 TH2D *MHAlphaEnergyTime::GetAlphaProjection(Axis_t lo, Axis_t up)
    246 {
    247     if (up < lo)
     228
     229// --------------------------------------------------------------------------
     230//
     231// Integrate fHist     (Alpha,E-est,Time) over the Time to get
     232//           fAlphaEest(Alpha,E-est)
     233//
     234TH2D *MHAlphaEnergyTime::IntegrateTime(const char *title, Bool_t draw)
     235{
     236    Int_t nzbins = fHist.GetNbinsZ();
     237    TAxis &axez  = *fHist.GetZaxis();
     238    axez.SetRange(1,nzbins);
     239
     240    TH2D &fAlphaEest = *(TH2D *)fHist.Project3D("exy");
     241
     242    fAlphaEest.SetTitle(title);
     243    fAlphaEest.SetXTitle("E-est [GeV]            ");
     244    fAlphaEest.SetYTitle("\\alpha  [  \\circ]");
     245
     246    if (draw == kTRUE)
    248247    {
    249         *fLog << err << fName << ": Alpha projection not possible: lo=" << lo << " up=" << up << endl;
    250         return NULL;
     248      TCanvas &c = *MakeDefCanvas(title, title);
     249
     250      gROOT->SetSelectedPad(NULL);
     251
     252      fAlphaEest.DrawCopy();
     253      gPad->SetLogx();
     254
     255      c.Modified();
     256      c.Update();
    251257    }
    252258
    253     TAxis &axe = *fHist.GetXaxis();
    254 
    255     Int_t ilo = axe.FindFixBin(lo);
    256     Int_t iup = axe.FindFixBin(up);
    257 
    258     const Double_t epslo1 = lo-axe.GetBinLowEdge(ilo);
    259     const Double_t epslo2 = axe.GetBinUpEdge(ilo)-lo;
    260 
    261     const Double_t epsup1 = up-axe.GetBinLowEdge(iup);
    262     const Double_t epsup2 = axe.GetBinUpEdge(iup)-up;
    263 
    264     const Double_t epslo = epslo1<epslo2 ? epslo1 : epslo2;
    265     const Double_t epsup = epsup1<epsup2 ? epsup1 : epsup2;
    266 
    267     if (epslo1>epslo2)
    268         ilo++;
    269 
    270     if (epsup1<epsup2)
    271         iup--;
    272 
    273     if (epslo>0.01*axe.GetBinWidth(ilo) || epsup>0.01*axe.GetBinWidth(iup))
     259    return &fAlphaEest;
     260}
     261
     262// --------------------------------------------------------------------------
     263//
     264// Integrate fHist     (Alpha,E-est,Time) over E-est to get
     265//           fAlphaTime(Alpha,Time)
     266//
     267TH2D *MHAlphaEnergyTime::IntegrateEest(const char *title, Bool_t draw)
     268{
     269    Int_t nybins = fHist.GetNbinsY();
     270    TAxis &axey  = *fHist.GetYaxis();
     271    axey.SetRange(1,nybins);
     272
     273    TH2D &fAlphaTime = *(TH2D *)fHist.Project3D("exz");
     274
     275    fAlphaTime.SetTitle(title);
     276    fAlphaTime.SetXTitle("Time [s]");
     277    fAlphaTime.SetYTitle("\\alpha  [  \\circ]");
     278
     279    if (draw == kTRUE)
    274280    {
    275         *fLog << err << fName << ": binning is not adequate for the requested projection:" << endl;
    276         *fLog << "Please specify a lower or upper limit which is not more than 1% away from a bin edge" << endl;
    277         *fLog << " epslo = " << epslo << endl;
    278         *fLog << " epsup = " << epsup << endl;
    279         *fLog << " dwl   = " << axe.GetBinWidth(ilo) << endl;
    280         *fLog << " dwu   = " << axe.GetBinWidth(iup) << endl;
    281         return NULL;
     281      TCanvas &c = *MakeDefCanvas(title, title);
     282
     283      gROOT->SetSelectedPad(NULL);
     284
     285      fAlphaTime.DrawCopy();
     286
     287      c.Modified();
     288      c.Update();
    282289    }
    283290
    284     axe.SetRange(ilo, iup);
    285 
    286     TH2D &h2D = *(TH2D *)fHist.Project3D("ezy");
    287 
    288     h2D.SetTitle("2D-plot  of time vs. E-est");
    289     h2D.SetXTitle("E-est [GeV]            ");
    290     h2D.SetYTitle("time [s]");
    291 
    292     return &h2D;
    293 }
    294 
    295 //---------------------------------------------------------
    296 //
    297 // Draw the projected histogram
    298 //
    299 TH2D *MHAlphaEnergyTime::DrawAlphaProjection(Axis_t lo, Axis_t up, Option_t *opt)
    300 {
    301     TH2D *h2D = GetAlphaProjection(lo, up);
    302 
    303     if (!h2D)
    304         return NULL;
    305 
    306     char txt[100];
    307     sprintf(txt, "No.of Gammas vs. E-est and Time (%.1f < alpha < %.1f deg)", lo, up);
    308 
    309     //    TCanvas *c = MakeDefCanvas("AlphaEnergyTime", "2D histogram of gamma signal in energy and time");
    310     TCanvas &c = *MakeDefCanvas("AlphaEnergyTime", txt);
    311 
    312     c.Divide(2, 2);
    313 
    314     gROOT->SetSelectedPad(NULL);
    315 
    316     TH1 *h;
    317 
    318     c.cd(1);
    319     h = h2D->ProjectionX("Eest", -1, 9999, "E");
    320     h->SetTitle("Distribution of E-est [GeV]");
    321     h->SetXTitle("E-est [GeV]            ");
    322     h->SetYTitle("Counts");
    323 
    324     h->Draw(opt);
    325     h->SetBit(kCanDelete);
    326     gPad->SetLogx();
    327 
    328     c.cd(2);
    329     h = h2D->ProjectionY("time", -1, 9999, "E");
    330     h->SetTitle("Distribution of time [s]");
    331     h->SetXTitle("time [s]");
    332     h->SetYTitle("Counts");
    333 
    334     h->Draw(opt);
    335     h->SetBit(kCanDelete);
    336 
    337     c.cd(3);
    338 
    339     h2D->DrawCopy(opt);
    340     gPad->SetLogx();
    341 
    342     c.Modified();
    343     c.Update();
    344 
    345     return h2D;
    346 }
    347 
     291    return &fAlphaTime;
     292}
     293
     294// --------------------------------------------------------------------------
     295//
     296// Integrate fHist (Alpha,E-est,Time) over Eest and Time to get
     297//           fAlpha(Alpha)
     298//
     299TH1D *MHAlphaEnergyTime::IntegrateEestTime(const char *title, Bool_t draw)
     300{
     301    Int_t nybins = fHist.GetNbinsY();
     302    TAxis &axey  = *fHist.GetYaxis();
     303    axey.SetRange(1,nybins);
     304
     305    Int_t nzbins = fHist.GetNbinsZ();
     306    TAxis &axez  = *fHist.GetZaxis();
     307    axez.SetRange(1,nzbins);
     308
     309    TH1D &fAlpha = *(TH1D *)fHist.Project3D("ex");
     310
     311    fAlpha.SetTitle(title);
     312    fAlpha.SetXTitle("\\alpha  [  \\circ]");
     313    fAlpha.SetYTitle("Counts");
     314
     315    if (draw == kTRUE)
     316    {
     317      TCanvas &c = *MakeDefCanvas(title, title);
     318
     319      gROOT->SetSelectedPad(NULL);
     320
     321      fAlpha.DrawCopy();
     322
     323      c.Modified();
     324      c.Update();
     325    }
     326
     327    return &fAlpha;
     328}
     329
     330
     331
     332
     333
     334
     335
Note: See TracChangeset for help on using the changeset viewer.