Ignore:
Timestamp:
04/27/04 18:51:50 (21 years ago)
Author:
gaug
Message:
*** empty log message ***
File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/MagicSoft/Mars/mjobs/MJCalibration.cc

    r3851 r3853  
    158158}
    159159
    160 // --------------------------------------------------------------------------
    161 //
    162 // Draw the MHCamera into the MStatusDisplay:
    163 //
    164 // 1) Draw it as histogram (MHCamera::DrawCopy("hist")
    165 // 2) Draw it as a camera, with MHCamera::SetPrettyPalette() set.
    166 // 3) If "rad" is not zero, draw its values vs. the radius from the camera center.
    167 //    (DrawRadialProfile())
    168 // 4) Depending on the variable "fit", draw the values projection on the y-axis
    169 //    (DrawProjection()):
    170 //    0: don't draw
    171 //    1: Draw fit to Single Gauss (for distributions flat-fielded over the whole camera)
    172 //    2: Draw and fit to Double Gauss (for distributions different for inner and outer pixels)
    173 //    3: Draw and fit to Triple Gauss (for distributions with inner, outer pixels and outliers)
    174 //    4: Draw and fit to Polynomial grade 0: (for the probability distributions)
    175 //    >4: Draw and don;t fit.
    176 //
    177 void MJCalibration::CamDraw(TCanvas &c, const Int_t x, const Int_t y, const MHCamera &cam1,
    178                             const Int_t fit, const Int_t rad)
    179 {
    180 
    181     c.cd(x);
    182     gPad->SetBorderMode(0);
    183     gPad->SetTicks();
    184     MHCamera *obj1=(MHCamera*)cam1.DrawCopy("hist");
    185     obj1->SetDirectory(NULL);
    186 
    187     c.cd(x+y);
    188     gPad->SetBorderMode(0);
    189     obj1->SetPrettyPalette();
    190     obj1->AddNotify(&fCalibrationCam);
    191     obj1->Draw();
    192 
    193     if (rad)
    194       {
    195         c.cd(x+2*y);
    196         gPad->SetBorderMode(0);
    197         gPad->SetTicks();
    198         DrawRadialProfile(obj1);
    199       }
    200    
    201 
    202     if (!fit)
    203         return;
    204 
    205     c.cd(rad ? x+3*y : x+2*y);
    206     gPad->SetBorderMode(0);
    207     gPad->SetTicks();
    208     DrawProjection(obj1, fit);
    209 }
    210160
    211161// --------------------------------------------------------------------------
     
    677627}
    678628
    679 // --------------------------------------------------------------------------
    680 //
    681 // Draw a projection of MHCamera onto the y-axis values. Depending on the
    682 // variable fit, the following fits are performed:
    683 //
    684 // 1: Single Gauss (for distributions flat-fielded over the whole camera)
    685 // 2: Double Gauss (for distributions different for inner and outer pixels)
    686 // 3: Triple Gauss (for distributions with inner, outer pixels and outliers)
    687 // 4: flat         (for the probability distributions)
    688 //
    689 // Moreover, sectors 6,1 and 2 of the camera and sectors 3,4 and 5 are
    690 // drawn separately, for inner and outer pixels.
    691 //
    692 void MJCalibration::DrawProjection(MHCamera *obj, Int_t fit) const
    693 {
    694  
    695   TH1D *obj2 = (TH1D*)obj->Projection(obj->GetName());
    696   obj2->SetDirectory(0);
    697   obj2->Draw();
    698   obj2->SetBit(kCanDelete);
    699  
    700   if (obj->GetGeomCam().InheritsFrom("MGeomCamMagic"))
    701     {
    702       TArrayI s0(3);
    703       s0[0] = 6;
    704       s0[1] = 1;
    705       s0[2] = 2;
    706      
    707       TArrayI s1(3);
    708       s1[0] = 3;
    709       s1[1] = 4;
    710       s1[2] = 5;
    711      
    712       TArrayI inner(1);
    713       inner[0] = 0;
    714      
    715       TArrayI outer(1);
    716       outer[0] = 1;
    717      
    718       // Just to get the right (maximum) binning
    719       TH1D *half[4];
    720       half[0] = obj->ProjectionS(s0, inner, "Sector 6-1-2 Inner");
    721       half[1] = obj->ProjectionS(s1, inner, "Sector 3-4-5 Inner");
    722       half[2] = obj->ProjectionS(s0, outer, "Sector 6-1-2 Outer");
    723       half[3] = obj->ProjectionS(s1, outer, "Sector 3-4-5 Outer");
    724      
    725       for (int i=0; i<4; i++)
    726         {
    727           half[i]->SetLineColor(kRed+i);
    728           half[i]->SetDirectory(0);
    729           half[i]->SetBit(kCanDelete);
    730           half[i]->Draw("same");
    731         }
    732     }
    733  
    734   const Double_t min   = obj2->GetBinCenter(obj2->GetXaxis()->GetFirst());
    735   const Double_t max   = obj2->GetBinCenter(obj2->GetXaxis()->GetLast());
    736   const Double_t integ = obj2->Integral("width")/2.5;
    737   const Double_t mean  = obj2->GetMean();
    738   const Double_t rms   = obj2->GetRMS();
    739   const Double_t width = max-min;
    740  
    741   const TString dgausformula = "([0]-[3])/[2]*exp(-0.5*(x-[1])*(x-[1])/[2]/[2])"
    742     "+[3]/[5]*exp(-0.5*(x-[4])*(x-[4])/[5]/[5])";
    743  
    744   const TString tgausformula = "([0]-[3]-[6])/[2]*exp(-0.5*(x-[1])*(x-[1])/[2]/[2])"
    745     "+[3]/[5]*exp(-0.5*(x-[4])*(x-[4])/[5]/[5])"
    746     "+[6]/[8]*exp(-0.5*(x-[7])*(x-[7])/[8]/[8])";
    747   TF1 *f=0;
    748   switch (fit)
    749     {
    750     case 1:
    751       f = new TF1("sgaus", "gaus(0)", min, max);
    752       f->SetLineColor(kYellow);
    753       f->SetBit(kCanDelete);
    754       f->SetParNames("Area", "#mu", "#sigma");
    755       f->SetParameters(integ/rms, mean, rms);
    756       f->SetParLimits(0, 0,   integ);
    757       f->SetParLimits(1, min, max);
    758       f->SetParLimits(2, 0,   width/1.5);
    759      
    760       obj2->Fit(f, "QLR");
    761       break;
    762      
    763     case 2:
    764       f = new TF1("dgaus",dgausformula.Data(),min,max);
    765       f->SetLineColor(kYellow);
    766       f->SetBit(kCanDelete);
    767       f->SetParNames("A_{tot}", "#mu1", "#sigma1", "A2", "#mu2", "#sigma2");
    768       f->SetParameters(integ,(min+mean)/2.,width/4.,
    769                        integ/width/2.,(max+mean)/2.,width/4.);
    770       // The left-sided Gauss
    771       f->SetParLimits(0,integ-1.5      , integ+1.5);
    772       f->SetParLimits(1,min+(width/10.), mean);
    773       f->SetParLimits(2,0              , width/2.);
    774       // The right-sided Gauss
    775       f->SetParLimits(3,0   , integ);
    776       f->SetParLimits(4,mean, max-(width/10.));
    777       f->SetParLimits(5,0   , width/2.);
    778       obj2->Fit(f,"QLRM");
    779       break;
    780      
    781     case 3:
    782       f = new TF1("tgaus",tgausformula.Data(),min,max);
    783       f->SetLineColor(kYellow);
    784       f->SetBit(kCanDelete);
    785       f->SetParNames("A_{tot}","#mu_{1}","#sigma_{1}",
    786                      "A_{2}","#mu_{2}","#sigma_{2}",
    787                      "A_{3}","#mu_{3}","#sigma_{3}");
    788       f->SetParameters(integ,(min+mean)/2,width/4.,
    789                        integ/width/3.,(max+mean)/2.,width/4.,
    790                        integ/width/3.,mean,width/2.);
    791       // The left-sided Gauss
    792       f->SetParLimits(0,integ-1.5,integ+1.5);
    793       f->SetParLimits(1,min+(width/10.),mean);
    794       f->SetParLimits(2,width/15.,width/2.);
    795       // The right-sided Gauss
    796       f->SetParLimits(3,0.,integ);
    797       f->SetParLimits(4,mean,max-(width/10.));
    798       f->SetParLimits(5,width/15.,width/2.);
    799       // The Gauss describing the outliers
    800       f->SetParLimits(6,0.,integ);
    801       f->SetParLimits(7,min,max);
    802       f->SetParLimits(8,width/4.,width/1.5);
    803       obj2->Fit(f,"QLRM");
    804       break;
    805      
    806     case 4:
    807       obj2->Fit("pol0", "Q");
    808       obj2->GetFunction("pol0")->SetLineColor(kYellow);
    809       break;
    810      
    811     case 9:
    812       break;
    813      
    814     default:
    815       obj2->Fit("gaus", "Q");
    816       obj2->GetFunction("gaus")->SetLineColor(kYellow);
    817       break;
    818     }
    819 }
    820 
    821 // --------------------------------------------------------------------------
    822 //
    823 // Draw a projection of MHCamera vs. the radius from the central pixel.
    824 //
    825 // The inner and outer pixels are drawn separately, both fitted by a polynomial
    826 // of grade 1.
    827 //
    828 void MJCalibration::DrawRadialProfile(MHCamera *obj) const
    829 {
    830  
    831   TProfile *obj2 = (TProfile*)obj->RadialProfile(obj->GetName());
    832   obj2->SetDirectory(0);
    833   obj2->Draw();
    834   obj2->SetBit(kCanDelete);
    835  
    836   if (obj->GetGeomCam().InheritsFrom("MGeomCamMagic"))
    837     {
    838 
    839       TArrayI s0(6);
    840       s0[0] = 1;
    841       s0[1] = 2;
    842       s0[2] = 3;
    843       s0[3] = 4;
    844       s0[4] = 5;
    845       s0[5] = 6;
    846 
    847       TArrayI inner(1);
    848       inner[0] = 0;
    849      
    850       TArrayI outer(1);
    851       outer[0] = 1;
    852      
    853       // Just to get the right (maximum) binning
    854       TProfile *half[2];
    855       half[0] = obj->RadialProfileS(s0, inner,Form("%s%s",obj->GetName(),"Inner"));
    856       half[1] = obj->RadialProfileS(s0, outer,Form("%s%s",obj->GetName(),"Outer"));
    857      
    858       for (Int_t i=0; i<2; i++)
    859         {
    860           Double_t min = obj->GetGeomCam().GetMinRadius(i);
    861           Double_t max = obj->GetGeomCam().GetMaxRadius(i);
    862 
    863           half[i]->SetLineColor(kRed+i);
    864           half[i]->SetDirectory(0);
    865           half[i]->SetBit(kCanDelete);
    866           half[i]->Draw("same");
    867           half[i]->Fit("pol1","Q","",min,max);
    868           half[i]->GetFunction("pol1")->SetLineColor(kRed+i);
    869           half[i]->GetFunction("pol1")->SetLineWidth(1);
    870         }
    871     }
    872 }
    873629
    874630
Note: See TracChangeset for help on using the changeset viewer.