Ignore:
Timestamp:
05/21/03 12:21:58 (22 years ago)
Author:
wittek
Message:
*** empty log message ***
Location:
trunk/MagicSoft/Mars/mhist
Files:
4 edited

Legend:

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

    r2112 r2128  
     1
    12/* ======================================================================== *\
    23!
     
    3233#include <TCanvas.h>
    3334
     35#include "MMcEvt.hxx"
    3436#include "MBlindPixels.h"
     37#include "MPedestalCam.h"
     38#include "MParList.h"
     39#include "MBinning.h"
     40
     41#include "MLog.h"
     42#include "MLogManip.h"
    3543
    3644ClassImp(MHBlindPixels);
     
    4149//
    4250MHBlindPixels::MHBlindPixels(const char *name, const char *title)
    43     : fHist(fName, fTitle, 577, -.5, 577-.5)
    4451{
    4552    fName  = name  ? name  : "MHBlindPixels";
    46     fTitle = title ? title : "Histogram for Blind Pixels";
     53    fTitle = title ? title : "Histogram for Blind Pixels vs. Theta";
    4754
    4855    //  - we initialize the histogram
    49     //  - we have to give diferent names for the diferent histograms because
     56    //  - we have to give different names for the different histograms because
    5057    //    root don't allow us to have diferent histograms with the same name
    5158
    52     fHist.SetName("1D-BlindPixels");
    53     fHist.SetTitle(fTitle);
     59    fBlindId.SetName("2D-IdBlindPixels");
     60    fBlindId.SetTitle("2D-IdBlindPixels");
     61    fBlindId.SetDirectory(NULL);
     62    fBlindId.SetXTitle("\\Theta [\\circ]");
     63    fBlindId.SetYTitle("pixel Id");
    5464
    55     fHist.SetDirectory(NULL);
     65    fBlindN.SetName("2D-NBlindPixels");
     66    fBlindN.SetTitle("2D-NBlindPixels");
     67    fBlindN.SetDirectory(NULL);
     68    fBlindN.SetXTitle("\\Theta [\\circ]");
     69    fBlindN.SetYTitle("number of blind pixels");
     70}
    5671
    57     fHist.SetXTitle("Id");
    58     fHist.SetYTitle("Counts");
     72// --------------------------------------------------------------------------
     73//
     74// Set the binnings and prepare the filling of the histogram
     75//
     76Bool_t MHBlindPixels::SetupFill(const MParList *plist)
     77{
     78    fMcEvt = (MMcEvt*)plist->FindObject("MMcEvt");
     79    if (!fMcEvt)
     80    {
     81        *fLog << err << "MMcEvt not found... aborting." << endl;
     82        return kFALSE;
     83    }
     84
     85    fPed = (MPedestalCam*)plist->FindObject("MPedestalCam");
     86    if (!fPed)
     87    {
     88        *fLog << err << "MPedestalCam not found... aborting." << endl;
     89        return kFALSE;
     90    }
     91
     92
     93    // Get Theta Binning
     94    MBinning* binstheta  = (MBinning*)plist->FindObject("BinningTheta", "MBinning");
     95    if (!binstheta)
     96    {
     97        *fLog << err << "Object 'BinningTheta' [MBinning] not found... aborting" << endl;
     98        return kFALSE;
     99    }
     100
     101    // Get binning for pixel number
     102    const UInt_t npix1 = fPed->GetSize()+1;
     103
     104    MBinning binspix("BinningPixel");
     105    binspix.SetEdges(npix1, -0.5, npix1-0.5);
     106
     107    // Set binnings in histograms
     108    SetBinning(&fBlindId, binstheta, &binspix);
     109    SetBinning(&fBlindN,  binstheta, &binspix);
     110
     111    return kTRUE;
    59112}
    60113
     
    68121    pad->SetBorderMode(0);
    69122
    70     fHist.Draw(option);
     123    pad->Divide(2,2);
     124
     125    TH1D *h;
     126
     127    pad->cd(1);
     128    fBlindId.Draw(option);
     129
     130    pad->cd(2);
     131    fBlindN.Draw(option);
     132
     133    pad->cd(3);
     134    gPad->SetBorderMode(0);
     135    h = ((TH2*)&fBlindId)->ProjectionY("ProjY-pixId", -1, 9999, "");
     136    h->SetDirectory(NULL);
     137    h->SetTitle("Distribution of blind pixel Id");
     138    h->SetXTitle("Id of blind pixel");
     139    h->SetYTitle("No. of events");
     140    h->Draw(option);
     141    h->SetBit(kCanDelete);
     142
     143    pad->cd(4);
     144    gPad->SetBorderMode(0);
     145    h = ((TH2*)&fBlindN)->ProjectionY("ProjY-pixN", -1, 9999, "");
     146    h->SetDirectory(NULL);
     147    h->SetTitle("Distribution of no.of blind pixels");
     148    h->SetXTitle("No. of blind pixels");
     149    h->SetYTitle("No. of events");
     150    h->Draw(option);
     151    h->SetBit(kCanDelete);
    71152
    72153    pad->Modified();
     
    79160        return kFALSE;
    80161
     162    Double_t theta = fMcEvt->GetTelescopeTheta()*kRad2Deg;
    81163    const MBlindPixels &bp = *(MBlindPixels*)par;
    82164
    83165    // FIXME: Slow.
    84     for (int i=0; i<577; i++)
     166    const UInt_t npix = fPed->GetSize();
     167
     168    UInt_t nb = 0;
     169    for (UInt_t i=0; i<npix; i++)
     170    {
    85171        if (bp.IsBlind(i))
    86             fHist.Fill(i, w);
     172        {
     173          fBlindId.Fill(theta, i, w);
     174          nb++;
     175        }   
     176    }
     177    fBlindN.Fill(theta, nb, w);
    87178
    88179    return kTRUE;
    89180}
     181
     182
     183
     184
     185
     186
     187
     188
     189
     190
     191
     192
  • trunk/MagicSoft/Mars/mhist/MHBlindPixels.h

    r2043 r2128  
    55#include "MH.h"
    66#endif
    7 #ifndef ROOT_TH1
    8 #include <TH1.h>
     7#ifndef ROOT_TH2
     8#include <TH2.h>
    99#endif
     10
     11class MPedestalCam;
     12class MMcEvt;
     13class MParList;
     14
    1015
    1116class MHBlindPixels : public MH
    1217{
    1318private:
    14     TH1D fHist; //
     19    MPedestalCam  *fPed;      //!
     20    MMcEvt        *fMcEvt;    //!
     21
     22    TH2D          fBlindId; // 2D-histogram : pixel Id vs. Theta
     23    TH2D          fBlindN;  // 2D-histogram : no.of blind pixels vs. Theta
    1524
    1625public:
    1726    MHBlindPixels(const char *name=NULL, const char *title=NULL);
    1827
    19     const TH1D *GetHist()       { return &fHist; }
    20     const TH1D *GetHist() const { return &fHist; }
     28    const TH2D *GetBlindId()       { return &fBlindId; }
     29    const TH2D *GetBlindId() const { return &fBlindId; }
    2130
    22     TH1 *GetHistByName(const TString name) { return &fHist; }
     31    const TH2D *GetBlindN()       { return &fBlindN; }
     32    const TH2D *GetBlindN() const { return &fBlindN; }
     33
     34    TH2 *GetBlinIdByName(const TString name) { return &fBlindId; }
     35    TH2 *GetBlinNByName(const TString name) { return &fBlindN; }
    2336
    2437    void Draw(Option_t* option = "");
     38    Bool_t SetupFill(const MParList *plist);
    2539    Bool_t Fill(const MParContainer *par, const Stat_t w=1);
    2640
    27     ClassDef(MHBlindPixels, 1)  // Histogram of blind pixels
     41    ClassDef(MHBlindPixels, 1)  // Histogram of blind pixel Id vs. Theta
    2842};
    2943
    3044#endif
     45
     46
  • trunk/MagicSoft/Mars/mhist/MHMatrix.cc

    r2104 r2128  
    788788    // Calculate normalization factors
    789789    //
    790     const int    nbins   = thsh.GetNbinsX();
    791     const double frombin = thsh.GetBinLowEdge(1);
    792     const double tobin   = thsh.GetBinLowEdge(nbins+1);
    793     const double dbin    = thsh.GetBinWidth(1);
     790    //const int    nbins   = thsh.GetNbinsX();
     791    //const double frombin = thsh.GetBinLowEdge(1);
     792    //const double tobin   = thsh.GetBinLowEdge(nbins+1);
     793    //const double dbin    = thsh.GetBinWidth(1);
     794
    794795    const Int_t  nrows   = fM.GetNrows();
    795796    const Int_t  ncols   = fM.GetNcols();
     
    798799    // set up the real histogram (distribution before)
    799800    //
    800     TH1F hth("th", "Distribution before reduction", nbins, frombin, tobin);
     801    //TH1F hth("th", "Distribution before reduction", nbins, frombin, tobin);
     802    TH1F hth;
     803    hth.SetNameTitle("th", "Distribution before reduction");
     804    SetBinning(&hth, &thsh);
    801805    hth.SetDirectory(NULL);
    802806    for (Int_t j=0; j<nrows; j++)
    803807        hth.Fill(fM(j, refcolumn));
    804808
    805     TH1F hthd("thd", "Correction factors", nbins, frombin, tobin);
     809    //TH1F hthd("thd", "Correction factors", nbins, frombin, tobin);
     810    TH1F hthd;
     811    hthd.SetNameTitle("thd", "Correction factors");
     812    SetBinning(&hthd, &thsh);
    806813    hthd.SetDirectory(NULL);
    807814    hthd.Divide((TH1F*)&thsh, &hth, 1, 1);
     
    840847    TVector v(fM.GetNrows());
    841848    v = TMatrixColumn(fM, refcolumn);
    842     v += -frombin;
    843     v *= 1/dbin;
     849    //v += -frombin;
     850    //v *= 1/dbin;
    844851
    845852    //
     
    850857    for (ir=0; ir<nrows; ir++)
    851858    {
    852         const Int_t indref = (Int_t)v(ind[ir]);
    853 
     859        // const Int_t indref = (Int_t)v(ind[ir]);
     860        const Int_t indref = hthd.FindBin(v(ind[ir])) - 1;
    854861        cumulweight[indref] += hthd.GetBinContent(indref+1);
    855862        if (cumulweight[indref]<=0.5)
  • trunk/MagicSoft/Mars/mhist/MHSigmaTheta.cc

    r2109 r2128  
    100100
    101101    MBinning binspix("BinningPixel");
    102     binspix.SetEdges(577, -0.5, 577.5);
     102    binspix.SetEdges(578, -0.5, 577.5);
    103103
    104104    SetBinning(&fSigmaTheta,    &binst, &binsb);
     
    169169
    170170    // Get binning for pixel number
    171     const UInt_t npix = fPed->GetSize();
     171    const UInt_t npix1 = fPed->GetSize()+1;
    172172
    173173    MBinning binspix("BinningPixel");
    174     binspix.SetEdges(npix, -0.5, 0.5+npix);
     174    binspix.SetEdges(npix1, -0.5, npix1-0.5);
    175175
    176176    // Set binnings in histograms
Note: See TracChangeset for help on using the changeset viewer.