Changeset 2880 for trunk/MagicSoft/Mars


Ignore:
Timestamp:
01/21/04 23:00:33 (21 years ago)
Author:
gaug
Message:
*** empty log message ***
Location:
trunk/MagicSoft/Mars
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • trunk/MagicSoft/Mars/Changelog

    r2879 r2880  
    2020       plexiglass is not intended to be calculated any more (previous
    2121       bug)
     22     - exclude excluded pixels in eventloop
    2223
    2324
  • trunk/MagicSoft/Mars/mcalib/MCalibrationCalc.cc

    r2879 r2880  
    261261      {
    262262       
    263         *fLog << "HALLO: " << fExcludedPixelsFile.Data() << endl;
    264 
    265263        fExcludedPixelsFile = gSystem->ExpandPathName(fExcludedPixelsFile.Data());
    266264       
     
    388386        const UInt_t pixid = pixel.GetPixelId();
    389387       
     388        MCalibrationPix &pix = (*fCalibrations)[pixid];
     389
     390        if (pix.IsExcluded())
     391          continue;
     392
    390393        MExtractedSignalPix &sig =  (*fSignals)[pixid];
    391394       
     
    394397        Float_t mtime  = sig.GetMeanArrivalTime();
    395398
    396         MCalibrationPix &pix = (*fCalibrations)[pixid];
    397399
    398400        switch(pixid)
  • trunk/MagicSoft/Mars/mcalib/MCalibrationCam.cc

    r2852 r2880  
    303303  *fLog << all << endl;
    304304 
     305  TIter Next3(fPixels);
     306    while ((pix=(MCalibrationPix*)Next3()))
     307      if (pix->IsExcluded())
     308        *fLog << all << pix->GetPixId() << endl;
     309
    305310  *fLog << all << fNumExcludedPixels << " excluded pixels " << endl;
    306311 
     
    425430// --------------------------------------------------------------------------
    426431//
    427 
     432//
    428433//
    429434Bool_t MCalibrationCam::CalcNumPhotInsidePlexiglass()
     
    442447                            *TMath::Power(10,gkCalibrationBlindPixelAttGreen) // correct for absorption
    443448                            * gkCalibrationInnerPixelArea;                    // correct for area
     449
     450     
    444451      break;
    445452    case kECBlue:
  • trunk/MagicSoft/Mars/mcalib/MHCalibrationBlindPixel.cc

    r2852 r2880  
    6767//
    6868MHCalibrationBlindPixel::MHCalibrationBlindPixel(const char *name, const char *title)
    69     :     fFitLegend(NULL), fFitOK(kFALSE),
     69    :     fHBlindPixelCharge(NULL),
     70          fHBlindPixelTime(NULL),
     71          fHBlindPixelChargevsN(NULL),
     72          fHBlindPixelPSD(NULL),
     73          fSinglePheFit(NULL), 
     74          fTimeGausFit(NULL),
     75          fSinglePhePedFit(NULL),
     76          fBlindPixelChargefirst(0.),
     77          fBlindPixelChargelast(0.),
     78          fBlindPixelChargenbins(0),
     79          fFitLegend(NULL), fFitOK(kFALSE),
    7080          fLambda(0.), fMu0(0.), fMu1(0.), fSigma0(0.), fSigma1(0.),
    7181          fLambdaErr(0.), fMu0Err(0.), fMu1Err(0.), fSigma0Err(0.), fSigma1Err(0.),   
     
    122132  delete fHBlindPixelTime;
    123133  delete fHBlindPixelChargevsN;
    124  
     134
     135  if (fHBlindPixelPSD)
     136    delete fHBlindPixelPSD;
     137
     138  if (fSinglePheFit) 
     139    delete fSinglePheFit;
     140  if (fTimeGausFit)
     141    delete fTimeGausFit;
     142  if(fSinglePhePedFit)
     143    delete fSinglePhePedFit;
     144
    125145}
    126146
     
    208228}
    209229
    210 
    211 TObject *MHCalibrationBlindPixel::DrawClone(Option_t *opt) const
     230TObject *MHCalibrationBlindPixel::DrawClone(Option_t *option) const
    212231{
    213232
    214233  gROOT->SetSelectedPad(NULL);
    215 
    216   TObject *newobj = Clone();
    217 
     234 
     235  //  TVirtualPad *padsav = gPad;
     236
     237  //  TObject *newobj = (TObject *)IsA()->New();
     238  //  Copy(*newobj);
     239 //  TObject *newobj = Clone();
     240  MHCalibrationBlindPixel *newobj = (MHCalibrationBlindPixel*)Clone();
     241
     242  if (!newobj)
     243    return 0;
    218244  newobj->SetBit(kCanDelete);
    219   if (!newobj)
    220      return 0;
    221 
    222   //  ((MHCalibrationBlindPixel*)newobj)->Draw(opt);
    223   newobj->Draw(opt);
     245
     246  if (strlen(option))
     247    newobj->Draw(option);
     248  //    ((MHCalibrationBlindPixel*)newobj)->Draw(option);
     249  //   newobj->Draw(option);
     250  else   
     251    newobj->Draw(GetDrawOption());
     252  //    ((MHCalibrationBlindPixel*)newobj)->Draw(GetDrawOption());
     253  //             newobj->Draw(GetDrawOption());
     254  //  if (padsav) padsav->cd();
     255 
    224256  return newobj;
    225257}
    226258 
    227 
    228259
    229260// -------------------------------------------------------------------------
     
    239270    TCanvas *c = MakeDefCanvas(this,550,700);
    240271
    241     c->Divide(2,2);
     272    c->Divide(2,3);
    242273
    243274    gROOT->SetSelectedPad(NULL);
    244275
    245276    c->cd(1);
     277    gPad->SetLogx(0);
    246278    gPad->SetLogy(1);
    247279    gPad->SetTicks();
    248280
    249     fHBlindPixelCharge->DrawCopy(opt);
     281    fHBlindPixelCharge->Draw(opt);
    250282   
    251283    if (fFitOK)
    252       fSinglePheFit.SetLineColor(kGreen);         
     284      fSinglePheFit->SetLineColor(kGreen);         
    253285    else
    254       fSinglePheFit.SetLineColor(kRed);
     286      fSinglePheFit->SetLineColor(kRed);
    255287   
    256     fSinglePheFit.DrawCopy("same");
     288    fSinglePheFit->Draw("same");
    257289    c->Modified();
    258290    c->Update();
    259291
    260     fSinglePhePedFit.SetLineColor(kBlue);
    261     fSinglePhePedFit.DrawCopy("same");
     292    fSinglePhePedFit->SetLineColor(kBlue);
     293    fSinglePhePedFit->Draw("same");
    262294
    263295    c->cd(2);
     
    269301    gPad->SetLogy(1);
    270302    gPad->SetBorderMode(0);
    271     fHBlindPixelTime->DrawCopy(opt);
    272    
    273     if (fHBlindPixelTime->GetFunction("GausTime"))
    274       {
    275         TF1 *tfit = fHBlindPixelTime->GetFunction("GausTime");
    276         if (tfit->GetProb() < 0.01)
    277           tfit->SetLineColor(kRed);
    278         else
    279           tfit->SetLineColor(kGreen);
    280        
    281         tfit->DrawCopy("same");
    282         c->Modified();
    283         c->Update();
    284       }
     303    fHBlindPixelTime->Draw(opt);
    285304   
    286305    c->cd(4);
    287306
    288     fHBlindPixelChargevsN->DrawCopy(opt);
     307    fHBlindPixelChargevsN->Draw(opt);
    289308
    290309    c->Modified();
    291310    c->Update();
     311
     312    c->cd(5);
     313   
     314    //    fHBlindPixelPSD = (TH1F*)MFFT::PowerSpectrumDensity(fHBlindPixelChargevsN);
     315    //    TH1F *hist = MFFT::PowerSpectrumDensity((*this)->fHBlindPixelChargevsN);
     316
     317    //    fHBlindPixelPSD->Draw(opt);
     318    c->Modified();
     319    c->Update();
     320
    292321}
    293322
     
    305334    }
    306335
    307   TF1 simulateSinglePhe;
    308  
    309   InitFit(simulateSinglePhe,fBlindPixelChargefirst,fBlindPixelChargelast);
    310  
     336  if (!InitFit(fBlindPixelChargefirst,fBlindPixelChargelast))
     337    return kFALSE;
     338
    311339  for (Int_t i=0;i<10000; i++)
    312     fHBlindPixelCharge->Fill(simulateSinglePhe.GetRandom());
     340    fHBlindPixelCharge->Fill(fSinglePheFit->GetRandom());
    313341 
    314342  return kTRUE;
    315343}
    316344
    317 void MHCalibrationBlindPixel::InitFit(TF1& f, Axis_t min, Axis_t max)
     345Bool_t MHCalibrationBlindPixel::InitFit(Axis_t min, Axis_t max)
    318346{
    319347 
     
    337365     
    338366    case kEPoisson4:
    339       f = TF1("SinglePheFit",&fPoissonKto4,min,max,6);
    340       f.SetParameters(lambda_guess,mu_0_guess,mu_1_guess,si_0_guess,si_1_guess,norm);
    341       f.SetParNames("#lambda","#mu_0","#mu_1","#sigma_0","#sigma_1","Area");
    342       f.SetParLimits(0,0.,1.);
    343       f.SetParLimits(1,min,(max-min)/1.5);
    344       f.SetParLimits(2,(max-min)/2.,(max-0.05*(max-min)));
    345       f.SetParLimits(3,1.0,(max-min)/2.0);
    346       f.SetParLimits(4,1.0,(max-min)/2.5);
    347       f.SetParLimits(5,norm-0.1,norm+0.1);
     367      fSinglePheFit = new TF1("SinglePheFit",&fPoissonKto4,min,max,6);
     368      fSinglePheFit->SetParameters(lambda_guess,mu_0_guess,mu_1_guess,si_0_guess,si_1_guess,norm);
     369      fSinglePheFit->SetParNames("#lambda","#mu_0","#mu_1","#sigma_0","#sigma_1","Area");
     370      fSinglePheFit->SetParLimits(0,0.,1.);
     371      fSinglePheFit->SetParLimits(1,min,(max-min)/1.5);
     372      fSinglePheFit->SetParLimits(2,(max-min)/2.,(max-0.05*(max-min)));
     373      fSinglePheFit->SetParLimits(3,1.0,(max-min)/2.0);
     374      fSinglePheFit->SetParLimits(4,1.0,(max-min)/2.5);
     375      fSinglePheFit->SetParLimits(5,norm-0.1,norm+0.1);
    348376      break;
    349377     
    350378    case kEPoisson5:
    351       f = TF1("SinglePheFit",&fPoissonKto5,min,max,6);
    352       f.SetParameters(lambda_guess,mu_0_guess,mu_1_guess,si_0_guess,si_1_guess,norm);
    353       f.SetParNames("#lambda","#mu_0","#mu_1","#sigma_0","#sigma_1","Area");
    354       f.SetParLimits(0,0.,1.);
    355       f.SetParLimits(1,min,(max-min)/1.5);
    356       f.SetParLimits(2,(max-min)/2.,(max-0.05*(max-min)));
    357       f.SetParLimits(3,1.0,(max-min)/2.0);
    358       f.SetParLimits(4,1.0,(max-min)/2.5);
    359       f.SetParLimits(5,norm-0.1,norm+0.1);
     379      fSinglePheFit = new TF1("SinglePheFit",&fPoissonKto5,min,max,6);
     380      fSinglePheFit->SetParameters(lambda_guess,mu_0_guess,mu_1_guess,si_0_guess,si_1_guess,norm);
     381      fSinglePheFit->SetParNames("#lambda","#mu_0","#mu_1","#sigma_0","#sigma_1","Area");
     382      fSinglePheFit->SetParLimits(0,0.,1.);
     383      fSinglePheFit->SetParLimits(1,min,(max-min)/1.5);
     384      fSinglePheFit->SetParLimits(2,(max-min)/2.,(max-0.05*(max-min)));
     385      fSinglePheFit->SetParLimits(3,1.0,(max-min)/2.0);
     386      fSinglePheFit->SetParLimits(4,1.0,(max-min)/2.5);
     387      fSinglePheFit->SetParLimits(5,norm-0.1,norm+0.1);
    360388      break;
    361389
    362390    case kEPoisson6:
    363       f = TF1("SinglePheFit",&fPoissonKto6,min,max,6);
    364       f.SetParameters(lambda_guess,mu_0_guess,mu_1_guess,si_0_guess,si_1_guess,norm);
    365       f.SetParNames("#lambda","#mu_0","#mu_1","#sigma_0","#sigma_1","Area");
    366       f.SetParLimits(0,0.,1.);
    367       f.SetParLimits(1,min,(max-min)/1.5);
    368       f.SetParLimits(2,(max-min)/2.,(max-0.05*(max-min)));
    369       f.SetParLimits(3,1.0,(max-min)/2.0);
    370       f.SetParLimits(4,1.0,(max-min)/2.5);
    371       f.SetParLimits(5,norm-0.1,norm+0.1);
     391      fSinglePheFit = new TF1("SinglePheFit",&fPoissonKto6,min,max,6);
     392      fSinglePheFit->SetParameters(lambda_guess,mu_0_guess,mu_1_guess,si_0_guess,si_1_guess,norm);
     393      fSinglePheFit->SetParNames("#lambda","#mu_0","#mu_1","#sigma_0","#sigma_1","Area");
     394      fSinglePheFit->SetParLimits(0,0.,1.);
     395      fSinglePheFit->SetParLimits(1,min,(max-min)/1.5);
     396      fSinglePheFit->SetParLimits(2,(max-min)/2.,(max-0.05*(max-min)));
     397      fSinglePheFit->SetParLimits(3,1.0,(max-min)/2.0);
     398      fSinglePheFit->SetParLimits(4,1.0,(max-min)/2.5);
     399      fSinglePheFit->SetParLimits(5,norm-0.1,norm+0.1);
    372400      break;
    373401
     
    380408    case kEMichele:
    381409      break;
    382      
     410
     411    default:
     412      *fLog << warn << "WARNING: Could not find Fit Function for Blind Pixel " << endl;
     413      return kFALSE;
     414      break;
    383415    }
    384 }
    385 
    386 void MHCalibrationBlindPixel::ExitFit(TF1 &f)
     416
     417  return kTRUE;
     418}
     419
     420void MHCalibrationBlindPixel::ExitFit(TF1 *f)
    387421{
    388422 
     
    398432    case kEPoisson6:
    399433    case kEPoisson7:
    400       fLambda = fSinglePheFit.GetParameter(0);
    401       fMu0    = fSinglePheFit.GetParameter(1);
    402       fMu1    = fSinglePheFit.GetParameter(2);
    403       fSigma0 = fSinglePheFit.GetParameter(3);
    404       fSigma1 = fSinglePheFit.GetParameter(4);
     434      fLambda = fSinglePheFit->GetParameter(0);
     435      fMu0    = fSinglePheFit->GetParameter(1);
     436      fMu1    = fSinglePheFit->GetParameter(2);
     437      fSigma0 = fSinglePheFit->GetParameter(3);
     438      fSigma1 = fSinglePheFit->GetParameter(4);
    405439     
    406       fLambdaErr = fSinglePheFit.GetParError(0);
    407       fMu0Err    = fSinglePheFit.GetParError(1);
    408       fMu1Err    = fSinglePheFit.GetParError(2);
    409       fSigma0Err = fSinglePheFit.GetParError(3);
    410       fSigma1Err = fSinglePheFit.GetParError(4);
     440      fLambdaErr = fSinglePheFit->GetParError(0);
     441      fMu0Err    = fSinglePheFit->GetParError(1);
     442      fMu1Err    = fSinglePheFit->GetParError(2);
     443      fSigma0Err = fSinglePheFit->GetParError(3);
     444      fSigma1Err = fSinglePheFit->GetParError(4);
    411445      break;
    412446    default:
     
    426460  rmax = (rmax != 0.) ? rmax : fBlindPixelChargelast;
    427461
    428   InitFit(fSinglePheFit,rmin,rmax);
    429 
    430   fHBlindPixelCharge->Fit(&fSinglePheFit,opt);
     462  if (!InitFit(rmin,rmax))
     463    return kFALSE;
     464
     465  fHBlindPixelCharge->Fit(fSinglePheFit,opt);
     466
    431467 
    432468  ExitFit(fSinglePheFit);
    433469
    434   fProb      = fSinglePheFit.GetProb();
    435   fChisquare = fSinglePheFit.GetChisquare();
    436   fNdf       = fSinglePheFit.GetNDF();
     470  fProb      = fSinglePheFit->GetProb();
     471  fChisquare = fSinglePheFit->GetChisquare();
     472  fNdf       = fSinglePheFit->GetNDF();
    437473
    438474  // Perform the cross-check fitting only the pedestal:
    439   fSinglePhePedFit = TF1("GausPed","gaus",rmin,fMu0);
    440   fHBlindPixelCharge->Fit(&fSinglePhePedFit,opt);
     475  fSinglePhePedFit = new TF1("GausPed","gaus",rmin,fMu0);
     476  fHBlindPixelCharge->Fit(fSinglePhePedFit,opt);
    441477
    442478  const Stat_t entries      = fHBlindPixelCharge->Integral("width");
    443479
    444   Double_t pedarea = fSinglePhePedFit.GetParameter(0)*gkSq2Pi*fSinglePhePedFit.GetParameter(2);
     480  Double_t pedarea = fSinglePhePedFit->GetParameter(0)*gkSq2Pi*fSinglePhePedFit->GetParameter(2);
    445481  fLambdaCheck     = TMath::Log(entries/pedarea);
    446   fLambdaCheckErr  = fSinglePhePedFit.GetParError(0)/fSinglePhePedFit.GetParameter(0)
    447                      + fSinglePhePedFit.GetParError(2)/fSinglePhePedFit.GetParameter(2);
     482  fLambdaCheckErr  = fSinglePhePedFit->GetParError(0)/fSinglePhePedFit->GetParameter(0)
     483                     + fSinglePhePedFit->GetParError(2)/fSinglePhePedFit->GetParameter(2);
    448484
    449485  *fLog << inf << "Results of the Blind Pixel Fit: " << endl;
     
    512548  const Double_t area_guess  = entries/gkSq2Pi;
    513549
    514   fTimeGausFit = TF1("GausTime","gaus",rmin,rmax); 
    515   fTimeGausFit.SetParameters(area_guess,mu_guess,sigma_guess);
    516   fTimeGausFit.SetParNames("Area","#mu","#sigma");
    517   fTimeGausFit.SetParLimits(0,0.,entries);
    518   fTimeGausFit.SetParLimits(1,rmin,rmax);
    519   fTimeGausFit.SetParLimits(2,0.,rmax-rmin);
    520 
    521   fHBlindPixelTime->Fit(&fTimeGausFit,opt);
    522   rmin = fTimeGausFit.GetParameter(1) - 2.*fTimeGausFit.GetParameter(2);
    523   rmax = fTimeGausFit.GetParameter(1) + 2.*fTimeGausFit.GetParameter(2);
    524   fTimeGausFit.SetRange(rmin,rmax); 
    525 
    526   fHBlindPixelTime->Fit(&fTimeGausFit,opt);
    527 
    528   fMeanTime     = fTimeGausFit.GetParameter(2);
    529   fSigmaTime    = fTimeGausFit.GetParameter(3);
    530   fMeanTimeErr  = fTimeGausFit.GetParError(2);
    531   fSigmaTimeErr = fTimeGausFit.GetParError(3);
     550  fTimeGausFit = new TF1("GausTime","gaus",rmin,rmax); 
     551  fTimeGausFit->SetParameters(area_guess,mu_guess,sigma_guess);
     552  fTimeGausFit->SetParNames("Area","#mu","#sigma");
     553  fTimeGausFit->SetParLimits(0,0.,entries);
     554  fTimeGausFit->SetParLimits(1,rmin,rmax);
     555  fTimeGausFit->SetParLimits(2,0.,rmax-rmin);
     556
     557  fHBlindPixelTime->Fit(fTimeGausFit,opt);
     558  rmin = fTimeGausFit->GetParameter(1) - 2.*fTimeGausFit->GetParameter(2);
     559  rmax = fTimeGausFit->GetParameter(1) + 2.*fTimeGausFit->GetParameter(2);
     560  fTimeGausFit->SetRange(rmin,rmax); 
     561
     562  fHBlindPixelTime->Fit(fTimeGausFit,opt);
     563
     564  fMeanTime     = fTimeGausFit->GetParameter(2);
     565  fSigmaTime    = fTimeGausFit->GetParameter(3);
     566  fMeanTimeErr  = fTimeGausFit->GetParError(2);
     567  fSigmaTimeErr = fTimeGausFit->GetParError(3);
    532568
    533569  *fLog << inf << "Results of the Times Fit: " << endl;
    534   *fLog << inf << "Chisquare: "   << fTimeGausFit.GetChisquare() << endl;
    535   *fLog << inf << "Ndf: "         << fTimeGausFit.GetNDF() << endl;
     570  *fLog << inf << "Chisquare: "   << fTimeGausFit->GetChisquare() << endl;
     571  *fLog << inf << "Ndf: "         << fTimeGausFit->GetNDF() << endl;
    536572
    537573  return kTRUE;
  • trunk/MagicSoft/Mars/mcalib/MHCalibrationBlindPixel.h

    r2852 r2880  
    1010#endif
    1111
     12#ifndef MARS_MFFT
     13#include "MFFT.h"
     14#endif
     15
    1216#ifndef ROOT_TH1
    1317#include "TH1.h"
     
    2529#include "TPaveText.h"
    2630#endif
     31
     32
    2733
    2834const Double_t NoWay = 10000000000.0;
     
    3440private:
    3541
    36   TH1F* fHBlindPixelCharge;        //-> Histogram with the single Phe spectrum
    37   TH1I* fHBlindPixelTime;          //-> Variance of summed FADC slices
    38   TH1I* fHBlindPixelChargevsN;     //-> Summed Charge vs. Event Nr.
    39  
    40   TF1 fSinglePheFit;
    41   TF1 fTimeGausFit; 
    42   TF1 fSinglePhePedFit;
     42  TH1F* fHBlindPixelCharge;        // Histogram with the single Phe spectrum
     43  TH1I* fHBlindPixelTime;          // Variance of summed FADC slices
     44  TH1I* fHBlindPixelChargevsN;     // Summed Charge vs. Event Nr.
     45  TH1F* fHBlindPixelPSD;           // Power spectrum density of fHBlindPixelChargevsN
     46 
     47  TF1 *fSinglePheFit;   
     48  TF1 *fTimeGausFit;   
     49  TF1 *fSinglePhePedFit;
    4350
    4451  Axis_t  fBlindPixelChargefirst;
    45   Axis_t  fBlindPixelChargelast;
     52  Axis_t  fBlindPixelChargelast; 
    4653  Int_t   fBlindPixelChargenbins;
    4754 
     
    4956  void DrawLegend();
    5057
    51   TPaveText *fFitLegend;                  //!
     58  TPaveText *fFitLegend;                 
    5259  Bool_t fFitOK; 
    5360 
     
    7380  Double_t  fSigmaTimeErr;
    7481 
    75   Double_t fLambdaCheck;
    76   Double_t fLambdaCheckErr;
     82  Double_t  fLambdaCheck;
     83  Double_t  fLambdaCheckErr;
    7784
    7885public:
     
    112119  const Bool_t IsFitOK()                { return fFitOK; }
    113120
     121  const TH1I *GetHBlindPixelChargevsN()  const  { return fHBlindPixelChargevsN;  }
     122  const TH1F *GetHBlindPixelPSD()      const  { return fHBlindPixelPSD;  }
     123 
    114124  // Draws
    115125  TObject *DrawClone(Option_t *option="") const;
     
    137147private:
    138148
    139   void InitFit(TF1& f, Axis_t min, Axis_t max);
    140   void ExitFit(TF1& f); 
     149  Bool_t InitFit(Axis_t min, Axis_t max);
     150  void ExitFit(TF1 *f); 
    141151 
    142152  inline static Double_t fFitFuncMichele(Double_t *x, Double_t *par)
Note: See TracChangeset for help on using the changeset viewer.