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

Legend:

Unmodified
Added
Removed
  • trunk/MagicSoft/Mars/manalysis/MPadSchweizer.cc

    r2070 r2128  
    8686#include "MPedestalCam.h"
    8787#include "MPedestalPix.h"
     88#include "MBlindPixels.h"
    8889
    8990ClassImp(MPadSchweizer);
     
    101102  fHSigmaPixTheta = NULL;
    102103  fHDiffPixTheta  = NULL;
     104  fHBlindPixIdTheta = NULL;
     105  fHBlindPixNTheta  = NULL;
    103106
    104107  fHSigmaPedestal = NULL;
     
    125128// fHSigmaPixTheta 3D-hiostogram (Theta, pixel, sigma)
    126129// fHDiffPixTheta  3D-histogram  (Theta, pixel, sigma^2-sigmabar^2)
    127 //
    128 //
    129 void MPadSchweizer::SetHistograms(TH2D *hist2, TH3D *hist3, TH3D *hist3Diff)
     130// fHBlindPixIdTheta 2D-histogram  (Theta, blind pixel Id)
     131// fHBlindPixNTheta  2D-histogram  (Theta, no.of blind pixels )
     132//
     133//
     134void MPadSchweizer::SetHistograms(TH2D *hist2, TH3D *hist3, TH3D *hist3Diff,
     135                                  TH2D *hist2Pix, TH2D *hist2PixN)
    130136{
    131137    fHSigmaTheta    = hist2;
    132138    fHSigmaPixTheta = hist3;
    133139    fHDiffPixTheta  = hist3Diff;
     140    fHBlindPixIdTheta = hist2Pix;
     141    fHBlindPixNTheta  = hist2PixN;
    134142
    135143    fHSigmaTheta->SetDirectory(NULL);
    136144    fHSigmaPixTheta->SetDirectory(NULL);
    137145    fHDiffPixTheta->SetDirectory(NULL);
     146    fHBlindPixIdTheta->SetDirectory(NULL);
     147    fHBlindPixNTheta->SetDirectory(NULL);
    138148
    139149    Print();
     
    171181Bool_t MPadSchweizer::PreProcess(MParList *pList)
    172182{
    173   if ( !fHSigmaTheta  || !fHSigmaPixTheta  || !fHDiffPixTheta)
     183  if ( !fHSigmaTheta  || !fHSigmaPixTheta  || !fHDiffPixTheta  ||
     184       !fHBlindPixIdTheta  ||  !fHBlindPixNTheta)
    174185  {
    175186       *fLog << err << "At least one of the histograms needed for the padding is not defined ... aborting." << endl;
     
    190201       return kFALSE;
    191202     }
    192  
     203
    193204   fCam = (MGeomCam*)pList->FindObject("MGeomCam");
    194205   if (!fCam)
     
    211222       return kFALSE;
    212223     }
     224
     225   fBlinds = (MBlindPixels*)pList->FindCreateObj("MBlindPixels");
     226   if (!fBlinds)
     227     {
     228       *fLog << err << "MBlindPixels not found... aborting." << endl;
     229       return kFALSE;
     230     }
    213231   
    214232
     
    296314  //-------------------------------------------
    297315  // for the current theta,
     316  // generate blind pixels according to the histograms
     317  //          fHBlindPixNTheta and fHBlindPixIDTheta
     318  //
     319
     320
     321  Int_t binPix = fHBlindPixNTheta->GetXaxis()->FindBin(theta);
     322
     323  if ( binPix < 1  ||  binPix > fHBlindPixNTheta->GetNbinsX() )
     324  {
     325    //*fLog << "MPadSchweizer::Process(); binNumber out of range : theta, binPix = "
     326    //      << theta << ",  " << binPix << ";  Skip event " << endl;
     327    // event cannot be padded; skip event
     328
     329    rc = 2;
     330    fErrors[rc]++;
     331    return kCONTINUE;
     332  }
     333
     334  // numBlind is the number of blind pixels in this event
     335  TH1D *nblind;
     336  UInt_t numBlind;
     337
     338  nblind = fHBlindPixNTheta->ProjectionY("", binPix, binPix, "");
     339  if ( nblind->GetEntries() == 0.0 )
     340  {
     341    *fLog << "MPadSchweizer::Process(); projection for Theta bin "
     342          << binPix << " has no entries; Skip event " << endl;
     343    // event cannot be padded; skip event
     344    delete nblind;
     345
     346    rc = 7;
     347    fErrors[rc]++;
     348    return kCONTINUE;
     349  }
     350  else
     351  {
     352    numBlind = (Int_t) (nblind->GetRandom()+0.5);
     353
     354    //*fLog << "numBlind = " << numBlind << endl;
     355  }
     356  delete nblind;
     357
     358
     359  // throw the Id of numBlind different pixels in this event
     360  TH1D *hblind;
     361  UInt_t idBlind;
     362  UInt_t listId[npix];
     363  UInt_t nlist = 0;
     364  Bool_t equal;
     365
     366  hblind = fHBlindPixIdTheta->ProjectionY("", binPix, binPix, "");
     367  if ( hblind->GetEntries() > 0.0 )
     368    for (UInt_t i=0; i<numBlind; i++)
     369    {
     370      while(1)
     371      {
     372        idBlind = (Int_t) (hblind->GetRandom()+0.5);
     373        equal = kFALSE;
     374        for (UInt_t j=0; j<nlist; j++)
     375          if (idBlind == listId[j])
     376          {
     377            equal = kTRUE;
     378            break;
     379          }
     380        if (!equal) break;
     381      }
     382      listId[nlist] = idBlind;
     383      nlist++;
     384
     385      fBlinds->SetPixelBlind(idBlind);
     386      //*fLog << "idBlind = " << idBlind << endl;
     387    }
     388  delete hblind;
     389
     390
     391  //-------------------------------------------
     392  // for the current theta,
    298393  // generate a sigmabar according to the histogram fHSigmaTheta
    299394  //
     
    301396  Int_t binNumber = fHSigmaTheta->GetXaxis()->FindBin(theta);
    302397
     398  if (binPix != binNumber)
     399  {
     400    cout << "The binnings of the 2 histograms are not identical; aborting"
     401         << endl;
     402    return kERROR;
     403  }
     404
    303405  TH1D *hsigma;
    304406
    305   if ( binNumber < 1  ||  binNumber > fHSigmaTheta->GetNbinsX() )
     407  hsigma = fHSigmaTheta->ProjectionY("", binNumber, binNumber, "");
     408  if ( hsigma->GetEntries() == 0.0 )
    306409  {
    307     //*fLog << "MPadSchweizer::Process(); binNumber out of range : theta, binNumber = "
    308     //      << theta << ",  " << binNumber << "; Skip event " << endl;
     410    *fLog << "MPadSchweizer::Process(); projection for Theta bin "
     411          << binNumber << " has no entries; Skip event " << endl;
    309412    // event cannot be padded; skip event
    310 
    311     rc = 2;
     413    delete hsigma;
     414
     415    rc = 3;
    312416    fErrors[rc]++;
    313417    return kCONTINUE;
     
    315419  else
    316420  {
    317     hsigma = fHSigmaTheta->ProjectionY("", binNumber, binNumber, "");
    318     if ( hsigma->GetEntries() == 0.0 )
    319     {
    320       *fLog << "MPadSchweizer::Process(); projection for Theta bin "
    321             << binNumber << " has no entries; Skip event " << endl;
    322       // event cannot be padded; skip event
    323       delete hsigma;
    324 
    325       rc = 3;
    326       fErrors[rc]++;
    327       return kCONTINUE;
    328     }
    329     else
    330     {
    331       sigmabar = hsigma->GetRandom();
    332 
    333       //*fLog << "Theta, bin number = " << theta << ",  " << binNumber
    334       //      << ",  sigmabar = " << sigmabar << endl;
    335     }
    336     delete hsigma;
    337   }
     421    sigmabar = hsigma->GetRandom();
     422     //*fLog << "Theta, bin number = " << theta << ",  " << binNumber      //      << ",  sigmabar = " << sigmabar << endl
     423  }
     424  delete hsigma;
     425
    338426  const Double_t sigmabar2 = sigmabar*sigmabar;
    339427
     
    644732          << "%) Evts skipped due to: No data for generating Sigma" << endl;
    645733
     734    *fLog << " " << setw(7) << fErrors[7] << " (" << setw(3)
     735          << (int)(fErrors[7]*100/GetNumExecutions())
     736          << "%) Evts skipped due to: No data for generating Blind pixels" << endl;
     737
    646738    *fLog << " " << fErrors[0] << " ("
    647739          << (int)(fErrors[0]*100/GetNumExecutions())
  • trunk/MagicSoft/Mars/manalysis/MPadSchweizer.h

    r2021 r2128  
    2020class MSigmabar;
    2121class MParList;
     22class MBlindPixels;
    2223
    2324class MPadSchweizer : public MTask
     
    2930    MMcEvt         *fMcEvt;
    3031    MPedestalCam   *fPed;
     32    MBlindPixels   *fBlinds;
    3133
    3234    Int_t          fPadFlag;
     
    3436    Int_t          fGroup;
    3537
    36     Int_t          fErrors[7];
     38    Int_t          fErrors[8];
    3739
    3840    // plots used for the padding
     41    TH2D           *fHBlindPixIdTheta; // 2D-histogram (blind pixel Id vs. Theta)
     42    TH2D           *fHBlindPixNTheta; // 2D-histogram (no.of blind pixels vs. Theta)
    3943    TH2D           *fHSigmaTheta;    // 2D-histogram (sigmabar vs. Theta)
    4044    TH3D           *fHSigmaPixTheta; // 3D-histogram (Theta, pixel, sigma)
     
    5357    ~MPadSchweizer();
    5458
    55     void SetHistograms(TH2D *hist2, TH3D *hist3, TH3D *hist3Diff);
     59    void SetHistograms(TH2D *hist2, TH3D *hist3, TH3D *hist3Diff,
     60                       TH2D *hist2Pix, TH2D *hist2PixN);
    5661
    5762    Bool_t PreProcess(MParList *pList);
Note: See TracChangeset for help on using the changeset viewer.