Changeset 3889 for trunk/MagicSoft/Mars/mjobs/MJPedestal.cc
- Timestamp:
- 04/29/04 15:48:38 (21 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/MagicSoft/Mars/mjobs/MJPedestal.cc
r3810 r3889 45 45 #include "MTaskList.h" 46 46 #include "MEvtLoop.h" 47 #include "MExtractor.h" 47 48 48 49 #include "MStatusDisplay.h" … … 62 63 63 64 using namespace std; 64 65 // -------------------------------------------------------------------------- 66 // 67 // Default constructor. 68 // 69 // Sets fRuns to 0, fExtractor to NULL, fDataCheck to kFALSE 70 // 65 71 MJPedestal::MJPedestal(const char *name, const char *title) 66 : fRuns(0), fDataCheck(kFALSE) 67 72 : fRuns(0), fExtractor(NULL), fDataCheck(kFALSE) 68 73 { 69 74 fName = name ? name : "MJPedestal"; … … 115 120 } 116 121 117 void MJPedestal::DrawProjection(MHCamera *obj1, Int_t fit) const118 {119 TH1D *obj2 = (TH1D*)obj1->Projection(obj1->GetName());120 obj2->SetDirectory(0);121 obj2->Draw();122 obj2->SetBit(kCanDelete);123 gPad->SetLogy();124 125 if (obj1->GetGeomCam().InheritsFrom("MGeomCamMagic"))126 {127 TArrayI s0(3);128 s0[0] = 6;129 s0[1] = 1;130 s0[2] = 2;131 132 TArrayI s1(3);133 s1[0] = 3;134 s1[1] = 4;135 s1[2] = 5;136 137 TArrayI inner(1);138 inner[0] = 0;139 140 TArrayI outer(1);141 outer[0] = 1;142 143 // Just to get the right (maximum) binning144 TH1D *half[4];145 half[0] = obj1->ProjectionS(s0, inner, "Sector 6-1-2 Inner");146 half[1] = obj1->ProjectionS(s1, inner, "Sector 3-4-5 Inner");147 half[2] = obj1->ProjectionS(s0, outer, "Sector 6-1-2 Outer");148 half[3] = obj1->ProjectionS(s1, outer, "Sector 3-4-5 Outer");149 150 for (int i=0; i<4; i++)151 {152 half[i]->SetLineColor(kRed+i);153 half[i]->SetDirectory(0);154 half[i]->SetBit(kCanDelete);155 half[i]->Draw("same");156 }157 }158 159 const Double_t min = obj2->GetBinCenter(obj2->GetXaxis()->GetFirst());160 const Double_t max = obj2->GetBinCenter(obj2->GetXaxis()->GetLast());161 const Double_t integ = obj2->Integral("width")/2.5066283;162 const Double_t mean = obj2->GetMean();163 const Double_t rms = obj2->GetRMS();164 const Double_t width = max-min;165 166 if (rms==0 || width==0)167 return;168 169 const TString dgausformula("([0]-[3])/[2]*exp(-0.5*(x-[1])*(x-[1])/[2]/[2])"170 "+[3]/[5]*exp(-0.5*(x-[4])*(x-[4])/[5]/[5])");171 172 TF1 *f=0;173 switch (fit)174 {175 // FIXME: MAYBE add function to TH1?176 case 0:177 f = new TF1("sgaus", "gaus(0)", min, max);178 f->SetLineColor(kYellow);179 f->SetBit(kCanDelete);180 f->SetParNames("Area", "#mu", "#sigma");181 f->SetParameters(integ/rms, mean, rms);182 f->SetParLimits(0, 0, integ);183 f->SetParLimits(1, min, max);184 f->SetParLimits(2, 0, width/1.5);185 obj2->Fit(f, "QLRM");186 break;187 188 case 1:189 f = new TF1("dgaus", dgausformula, min, max);190 f->SetLineColor(kYellow);191 f->SetBit(kCanDelete);192 f->SetParNames("A_{tot}", "#mu_{1}", "#sigma_{1}", "A_{2}", "#mu_{2}", "#sigma_{2}");193 f->SetParameters(integ, (min+mean)/2, width/4,194 integ/width/2, (max+mean)/2, width/4);195 // The left-sided Gauss196 f->SetParLimits(0, integ-1.5, integ+1.5);197 f->SetParLimits(1, min+(width/10), mean);198 f->SetParLimits(2, 0, width/2);199 // The right-sided Gauss200 f->SetParLimits(3, 0, integ);201 f->SetParLimits(4, mean, max-(width/10));202 f->SetParLimits(5, 0, width/2);203 obj2->Fit(f, "QLRM");204 break;205 206 default:207 obj2->Fit("gaus", "Q");208 obj2->GetFunction("gaus")->SetLineColor(kYellow);209 break;210 }211 }212 213 void MJPedestal::CamDraw(TCanvas &c, Int_t x, Int_t y, MHCamera &cam1, Int_t fit)214 {215 c.cd(x);216 gPad->SetBorderMode(0);217 MHCamera *obj1=(MHCamera*)cam1.DrawCopy("hist");218 219 obj1->AddNotify(&fPedestalCam);220 221 c.cd(x+y);222 gPad->SetBorderMode(0);223 obj1->Draw();224 225 c.cd(x+2*y);226 gPad->SetBorderMode(0);227 DrawProjection(obj1, fit);228 }229 122 230 123 void MJPedestal::DisplayResult(MParList &plist) … … 251 144 // Create container to display 252 145 // 253 MHCamera disp0(geomcam, "MPedestalCam;ped", "Pedestal s");254 MHCamera disp1(geomcam, "MPedestalCam; var", "Sigma Pedestal");146 MHCamera disp0(geomcam, "MPedestalCam;ped", "Pedestal"); 147 MHCamera disp1(geomcam, "MPedestalCam;RMS", "Ped. RMS"); 255 148 256 149 disp0.SetCamContent(fPedestalCam, 0); … … 269 162 c3.Divide(2,3); 270 163 271 CamDraw(c3, 1, 2, disp0, 0);272 CamDraw(c3, 2, 2, disp1, 1);164 CamDraw(c3, 1, 2, disp0, 1); 165 CamDraw(c3, 2, 2, disp1, 6); 273 166 } 274 167 … … 368 261 MPedCalcPedRun pedcalc; 369 262 263 if (fExtractor) 264 { 265 pedcalc.SetWindowSize((Int_t)fExtractor->GetNumHiGainSamples()); 266 pedcalc.SetRange(fExtractor->GetHiGainFirst(), fExtractor->GetHiGainLast()); 267 } 268 else 269 { 270 *fLog << warn << GetDescriptor() 271 << ": No extractor has been chosen, take default number of FADC samples " << endl; 272 } 273 370 274 tlist.AddToList(&geomapl); 371 275 // tlist.AddToList(&merge);
Note:
See TracChangeset
for help on using the changeset viewer.