source: trunk/MagicSoft/Mars/macros/calibration.C@ 3567

Last change on this file since 3567 was 3566, checked in by gaug, 21 years ago
*** empty log message ***
File size: 19.9 KB
Line 
1/* ======================================================================== *\
2!
3! *
4! * This file is part of MARS, the MAGIC Analysis and Reconstruction
5! * Software. It is distributed to you in the hope that it can be a useful
6! * and timesaving tool in analysing Data of imaging Cerenkov telescopes.
7! * It is distributed WITHOUT ANY WARRANTY.
8! *
9! * Permission to use, copy, modify and distribute this software and its
10! * documentation for any purpose is hereby granted without fee,
11! * provided that the above copyright notice appear in all copies and
12! * that both that copyright notice and this permission notice appear
13! * in supporting documentation. It is provided "as is" without express
14! * or implied warranty.
15! *
16!
17!
18! Author(s): Markus Gaug, 11/2003 <mailto:markus@ifae.es>
19!
20! Copyright: MAGIC Software Development, 2000-2003
21!
22!
23\* ======================================================================== */
24#include "MAGIC.h"
25
26void calibration()
27{
28
29 const TString inpath = "/mnt/Data/rootdata/CrabNebula/2004_01_27/";
30
31 MRunIter pruns;
32 MRunIter cruns;
33
34 pruns.AddRun(12386,inpath);
35 cruns.AddRun(12525,inpath);
36
37 gStyle->SetOptStat(1111);
38 gStyle->SetOptFit();
39
40 MStatusDisplay *display = new MStatusDisplay;
41 display->SetUpdateTime(3000);
42 display->Resize(850,700);
43
44 MBadPixelsCam badcam;
45 badcam.AsciiRead("badpixels.dat");
46
47 /************************************/
48 /* FIRST LOOP: PEDESTAL COMPUTATION */
49 /************************************/
50
51 MJPedestal pedloop;
52 pedloop.SetInput(&pruns);
53 pedloop.SetDisplay(display);
54 pedloop.SetBadPixels(badcam);
55
56 if (!pedloop.Process())
57 return;
58
59 //
60 // Now the short version:
61 //
62 /*
63 MJCalibration calloop;
64 calloop.SetInput(&cruns);
65 calloop.SetDisplay(display);
66 calloop.SetBadPixels(badcam);
67 if (!calloop.Process(pedloop.GetPedestalCam()))
68 return;
69 #if 0
70 */
71 //
72 // The longer version:
73 //
74
75 //
76 // Create a empty Parameter List and an empty Task List
77 //
78 MParList plist;
79 MTaskList tlist;
80 plist.AddToList(&tlist);
81 plist.AddToList(&pedloop.GetPedestalCam());
82 plist.AddToList(&badcam);
83
84 gLog << endl;;
85 gLog << "Calculate MCalibrationCam from Runs " << cruns.GetRunsAsString() << endl;
86 gLog << endl;
87
88 MReadMarsFile read("Events");
89 read.DisableAutoScheme();
90 static_cast<MRead&>(read).AddFiles(cruns);
91
92 MGeomCamMagic geomcam;
93 MExtractedSignalCam sigcam;
94 MArrivalTimeCam timecam;
95 MCalibrationChargeCam calcam;
96 MCalibrationChargePINDiode pindiode;
97 MCalibrationChargeBlindPix blindpix;
98
99 MHCalibrationRelTimeCam histtime;
100 MHCalibrationChargeCam histcharge;
101 MHCalibrationChargePINDiode histpin;
102 MHCalibrationChargeBlindPix histblind;
103 histblind.SetSinglePheCut(1000);
104 //
105 // As long, as we don't have digital modules,
106 // we have to set the color of the pulser LED by hand
107 //
108 blindpix.SetColor(kCT1);
109 // pindiode.SetColor(kCT1);
110 //
111 // Get the previously created MPedestalCam into the new Parameter List
112 //
113 plist.AddToList(&geomcam);
114 plist.AddToList(&sigcam);
115 plist.AddToList(&timecam);
116 plist.AddToList(&calcam);
117 plist.AddToList(&histtime);
118 plist.AddToList(&histcharge);
119 // plist.AddToList(&histpin);
120 plist.AddToList(&histblind);
121 plist.AddToList(&pedloop.GetBadPixels());
122
123 //
124 // We saw that the signal jumps between slices,
125 // thus take the sliding window
126 //
127 MExtractSignal2 sigcalc2;
128 MExtractPINDiode pincalc;
129 MExtractBlindPixel blindcalc;
130 sigcalc2.SetRange(2,15,6,5,14,6);
131 blindcalc.SetRange(11,29);
132
133 MArrivalTimeCalc2 timecalc;
134 MCalibrationChargeCalc calcalc;
135 MGeomApply geomapl;
136
137 MFillH filltime( "MHCalibrationRelTimeCam" , "MArrivalTimeCam");
138 // MFillH fillpin ("MHCalibrationChargePINDiode", "MExtractedSignalPINDiode");
139 MFillH fillblind("MHCalibrationChargeBlindPix", "MExtractedSignalBlindPixel");
140 MFillH fillcam ("MHCalibrationChargeCam" , "MExtractedSignalCam");
141
142 //
143 // Skip the HiGain vs. LoGain calibration
144 //
145 calcalc.SkipHiLoGainCalibration();
146
147 //
148 // Apply a filter against cosmics
149 // (was directly in MCalibrationCalc in earlier versions)
150 //
151 MFCosmics cosmics;
152 MContinue cont(&cosmics);
153
154 tlist.AddToList(&read);
155 tlist.AddToList(&geomapl);
156 tlist.AddToList(&sigcalc2);
157 tlist.AddToList(&blindcalc);
158 // tlist.AddToList(&pincalc);
159 //
160 // In case, you want to skip the cosmics rejection,
161 // uncomment the next line
162 //
163 tlist.AddToList(&cont);
164 //
165 // In case, you want to skip the somewhat lengthy calculation
166 // of the arrival times using a spline, uncomment the next two lines
167 //
168 tlist.AddToList(&timecalc);
169 tlist.AddToList(&filltime);
170 // tlist.AddToList(&fillpin);
171 tlist.AddToList(&fillblind);
172 tlist.AddToList(&fillcam);
173 //
174 tlist.AddToList(&calcalc);
175 //
176 // Create and setup the eventloop
177 //
178 MEvtLoop evtloop;
179 evtloop.SetParList(&plist);
180 evtloop.SetDisplay(display);
181
182 //
183 // Execute second analysis
184 //
185 if (!evtloop.Eventloop())
186 return;
187
188 tlist.PrintStatistics();
189
190 //
191 // print the most important results of all pixels to a file
192 //
193 /*
194 MLog gauglog;
195 gauglog.SetOutputFile(Form("%s%s",calcam.GetName(),".txt"),1);
196 calcam.SetLogStream(&gauglog);
197 badcam.Print();
198 calcam.SetLogStream(&gLog);
199 */
200 //
201 // just one example how to get the plots of individual pixels
202 //
203 // histblind.DrawClone("all");
204 // histcharge[5].DrawClone("all");
205 // histcharge(5).DrawClone("all");
206 // histtime[5].DrawClone("fourierevents");
207
208 // Create histograms to display
209 MHCamera disp1 (geomcam, "Cal;Charge", "Fitted Mean Charges");
210 MHCamera disp2 (geomcam, "Cal;SigmaCharge", "Sigma of Fitted Charges");
211 MHCamera disp3 (geomcam, "Cal;FitProb", "Probability of Fit");
212 MHCamera disp4 (geomcam, "Cal;RSigma", "Reduced Sigmas");
213 MHCamera disp5 (geomcam, "Cal;RSigma/Charge", "Reduced Sigma per Charge");
214 MHCamera disp6 (geomcam, "Cal;FFactorPhe", "Nr. of Photo-electrons (F-Factor Method)");
215 MHCamera disp7 (geomcam, "Cal;FFactorConv", "Conversion Factor to photons (F-Factor Method)");
216 MHCamera disp8 (geomcam, "Cal;FFactorFFactor", "Total F-Factor (F-Factor Method)");
217 MHCamera disp9 (geomcam, "Cal;BlindPixConv", "Conversion Factor to photons (Blind Pixel Method)");
218 MHCamera disp10 (geomcam, "Cal;BlindPixFFactor","Total F-Factor (Blind Pixel Method)");
219 MHCamera disp11 (geomcam, "Cal;PINDiodeConv", "Conversion Factor tp photons (PIN Diode Method)");
220 MHCamera disp12 (geomcam, "Cal;PINDiodeFFactor","Total F-Factor (PIN Diode Method)");
221 MHCamera disp13 (geomcam, "Cal;Excluded", "Pixels previously excluded");
222 MHCamera disp14 (geomcam, "Cal;NotFitted", "Pixels that could not be fitted");
223 MHCamera disp15 (geomcam, "Cal;NotFitValid", "Pixels with not valid fit results");
224 MHCamera disp16 (geomcam, "Cal;HiGainOscillating", "Oscillating Pixels HI Gain");
225 MHCamera disp17 (geomcam, "Cal;LoGainOscillating", "Oscillating Pixels LO Gain");
226 MHCamera disp18 (geomcam, "Cal;HiGainPickup", "Number Pickup events Hi Gain");
227 MHCamera disp19 (geomcam, "Cal;LoGainPickup", "Number Pickup events Lo Gain");
228 MHCamera disp20 (geomcam, "Cal;Saturation", "Pixels with saturated Hi Gain");
229 MHCamera disp21 (geomcam, "Cal;FFactorValid", "Pixels with valid F-Factor calibration");
230 MHCamera disp22 (geomcam, "Cal;BlindPixelValid", "Pixels with valid BlindPixel calibration");
231 MHCamera disp23 (geomcam, "Cal;PINdiodeFFactorValid", "Pixels with valid PINDiode calibration");
232
233 MHCamera disp24 (geomcam, "Cal;Ped", "Pedestals");
234 MHCamera disp25 (geomcam, "Cal;PedRms", "Pedestal RMS");
235
236 MHCamera disp26 (geomcam, "time;Time", "Rel. Arrival Times");
237 MHCamera disp27 (geomcam, "time;SigmaTime", "Sigma of Rel. Arrival Times");
238 MHCamera disp28 (geomcam, "time;TimeProb", "Probability of Time Fit");
239 MHCamera disp29 (geomcam, "time;NotFitValid", "Pixels with not valid fit results");
240 MHCamera disp30 (geomcam, "time;Oscillating", "Oscillating Pixels");
241
242 MHCamera disp31 (geomcam, "Cal;AbsTimeMean", "Abs. Arrival Times");
243 MHCamera disp32 (geomcam, "Cal;AbsTimeRms", "RMS of Arrival Times");
244
245 // Fitted charge means and sigmas
246 disp1.SetCamContent(calcam, 0);
247 disp1.SetCamError( calcam, 1);
248 disp2.SetCamContent(calcam, 2);
249 disp2.SetCamError( calcam, 3);
250
251 // Fit probabilities
252 disp3.SetCamContent(calcam, 4);
253
254 // Reduced Sigmas and reduced sigmas per charge
255 disp4.SetCamContent(calcam, 5);
256 disp4.SetCamError( calcam, 6);
257 disp5.SetCamContent(calcam, 7);
258 disp5.SetCamError( calcam, 8);
259
260 // F-Factor Method
261 disp6.SetCamContent(calcam, 9);
262 disp6.SetCamError( calcam, 10);
263 disp7.SetCamContent(calcam, 11);
264 disp7.SetCamError( calcam, 12);
265 disp8.SetCamContent(calcam, 13);
266 disp8.SetCamError( calcam, 14);
267
268 // Blind Pixel Method
269 disp9.SetCamContent(calcam, 16);
270 disp9.SetCamError( calcam, 17);
271 disp10.SetCamContent(calcam,18);
272 disp10.SetCamError( calcam,19);
273
274 // PIN Diode Method
275 disp11.SetCamContent(calcam,21);
276 disp11.SetCamError( calcam,22);
277 disp12.SetCamContent(calcam,23);
278 disp12.SetCamError( calcam,24);
279
280 // Pixels with defects
281 disp13.SetCamContent(calcam,26);
282 disp14.SetCamContent(badcam,7);
283 disp15.SetCamContent(badcam,9);
284 disp16.SetCamContent(badcam,16);
285 disp17.SetCamContent(badcam,15);
286 disp18.SetCamContent(calcam,27);
287 disp19.SetCamContent(calcam,28);
288
289 // Lo Gain calibration
290 disp20.SetCamContent(calcam,29);
291
292 // Valid flags
293 disp21.SetCamContent(calcam,15);
294 disp22.SetCamContent(calcam,20);
295 disp23.SetCamContent(calcam,25);
296
297 // Pedestals
298 disp24.SetCamContent(calcam,30);
299 disp24.SetCamError( calcam,31);
300 disp25.SetCamContent(calcam,32);
301 disp25.SetCamError( calcam,33);
302
303 // Relative Times
304 disp26.SetCamContent(histtime,0);
305 disp26.SetCamError( histtime,1);
306 disp27.SetCamContent(histtime,2);
307 disp27.SetCamError( histtime,3);
308 disp28.SetCamContent(histtime,4);
309 disp29.SetCamContent(histtime,5);
310 disp30.SetCamContent(histtime,6);
311
312 // Absolute Times
313 disp31.SetCamContent(calcam,34);
314 disp31.SetCamError( calcam,35);
315 disp32.SetCamContent(calcam,35);
316
317 disp1.SetYTitle("Charge [FADC units]");
318 disp2.SetYTitle("\\sigma_{Charge} [FADC units]");
319 disp3.SetYTitle("P_{Charge} [1]");
320
321 disp4.SetYTitle("\\sqrt{\\sigma^{2}_{Charge} - RMS^{2}_{Ped}} [FADC Counts]");
322 disp5.SetYTitle("Reduced Sigma / Mean Charge [1]");
323
324 disp6.SetYTitle("Nr. Photo-electrons [1]");
325 disp7.SetYTitle("Conversion Factor [Ph/FADC Count]");
326 disp8.SetYTitle("\\sqrt{N_{Ph}}*\\sigma_{Charge}/\\mu_{Charge} [1] ");
327
328 disp9.SetYTitle("Conversion Factor [Phot/FADC Count]");
329 disp10.SetYTitle("\\sqrt{N_{Ph}}*\\sigma_{Charge}/\\mu_{Charge} [1]");
330
331 disp11.SetYTitle("Conversion Factor [Phot/FADC Count]");
332 disp12.SetYTitle("\\sqrt{N_{Ph}}*\\sigma_{Charge}/\\mu_{Charge} [1]");
333
334 disp13.SetYTitle("[1]");
335 disp14.SetYTitle("[1]");
336 disp15.SetYTitle("[1]");
337 disp16.SetYTitle("[1]");
338 disp17.SetYTitle("[1]");
339 disp18.SetYTitle("[1]");
340 disp19.SetYTitle("[1]");
341 disp20.SetYTitle("[1]");
342 disp21.SetYTitle("[1]");
343 disp22.SetYTitle("[1]");
344 disp23.SetYTitle("[1]");
345
346 disp24.SetYTitle("Ped [FADC Counts ]");
347 disp25.SetYTitle("RMS_{Ped} [FADC Counts ]");
348
349 disp26.SetYTitle("Time Offset [ns]");
350 disp27.SetYTitle("Timing resolution [ns]");
351 disp28.SetYTitle("P_{Time} [1]");
352
353 disp29.SetYTitle("[1]");
354 disp30.SetYTitle("[1]");
355
356 disp31.SetYTitle("Mean Abs. Time [FADC slice]");
357 disp32.SetYTitle("RMS Abs. Time [FADC slices]");
358
359 gStyle->SetOptStat(1111);
360 gStyle->SetOptFit();
361
362 // Charges
363 TCanvas &c1 = display->AddTab("Fit.Charge");
364 c1.Divide(2, 4);
365
366 CamDraw(c1, disp1,calcam,1, 2 , 2);
367 CamDraw(c1, disp2,calcam,2, 2 , 2);
368
369 // Fit Probability
370 TCanvas &c2 = display->AddTab("Fit.Prob");
371 c2.Divide(1,4);
372
373 CamDraw(c2, disp3,calcam,1,1,4);
374
375 // Reduced Sigmas
376 TCanvas &c3 = display->AddTab("Red.Sigma");
377 c3.Divide(2,4);
378
379 CamDraw(c3, disp4,calcam,1, 2 , 2);
380 CamDraw(c3, disp5,calcam,2, 2 , 2);
381
382
383 // F-Factor Method
384 TCanvas &c4 = display->AddTab("F-Factor");
385 c4.Divide(3,4);
386
387 CamDraw(c4, disp6,calcam,1, 3 , 2);
388 CamDraw(c4, disp7,calcam,2, 3 , 2);
389 CamDraw(c4, disp8,calcam,3, 3 , 2);
390
391
392 // Blind Pixel Method
393 TCanvas &c5 = display->AddTab("BlindPix");
394 c5.Divide(2, 4);
395
396 CamDraw(c5, disp9 ,calcam,1,2, 2);
397 CamDraw(c5, disp10,calcam,2,2, 2);
398
399 // PIN Diode Method
400 TCanvas &c6 = display->AddTab("PINDiode");
401 c6.Divide(2,4);
402
403 CamDraw(c6, disp11,calcam,1,2, 2);
404 CamDraw(c6, disp12,calcam,2,2, 2);
405
406 // Defects
407 TCanvas &c7 = display->AddTab("Defects");
408 c7.Divide(4,2);
409
410 CamDraw(c7, disp13,calcam,1,4, 0);
411 CamDraw(c7, disp14,calcam,2,4, 0);
412 CamDraw(c7, disp18,calcam,3,4, 0);
413 CamDraw(c7, disp19,calcam,4,4, 0);
414
415 // BadCam
416 TCanvas &c8 = display->AddTab("Defects");
417 c8.Divide(3,2);
418
419 CamDraw(c8, disp15,badcam,1,3, 0);
420 CamDraw(c8, disp16,badcam,2,3, 0);
421 CamDraw(c8, disp17,badcam,3,3, 0);
422
423 // Valid flags
424 TCanvas &c9 = display->AddTab("Validity");
425 c9.Divide(4,2);
426
427 CamDraw(c9, disp20,calcam,1,4,0);
428 CamDraw(c9, disp21,calcam,2,4,0);
429 CamDraw(c9, disp22,calcam,3,4,0);
430 CamDraw(c9, disp23,calcam,4,4,0);
431
432 // Pedestals
433 TCanvas &c10 = display->AddTab("Pedestals");
434 c10.Divide(2,4);
435
436 CamDraw(c10,disp24,calcam,1,2,1);
437 CamDraw(c10,disp25,calcam,2,2,2);
438
439 // Rel. Times
440 TCanvas &c11 = display->AddTab("Fitted Rel. Times");
441 c11.Divide(3,4);
442
443 CamDraw(c11,disp26,calcam,1,3,2);
444 CamDraw(c11,disp27,calcam,2,3,2);
445 CamDraw(c11,disp28,calcam,3,3,4);
446
447 // Time Defects
448 TCanvas &c12 = display->AddTab("Time Def.");
449 c12.Divide(2,2);
450
451 CamDraw(c12, disp29,calcam,1,2, 0);
452 CamDraw(c12, disp30,calcam,2,2, 0);
453
454 // Abs. Times
455 TCanvas &c13 = display->AddTab("Abs. Times");
456 c13.Divide(2,4);
457
458 CamDraw(c13,disp31,calcam,1,2,2);
459 CamDraw(c13,disp32,calcam,2,2,2);
460#endif
461
462}
463
464
465void CamDraw(TCanvas &c, MHCamera &cam, TObject &evt, Int_t i, Int_t j, Int_t fit)
466{
467
468 TArrayI s0(6);
469 s0[0] = 1;
470 s0[1] = 2;
471 s0[2] = 3;
472 s0[3] = 4;
473 s0[4] = 5;
474 s0[5] = 6;
475
476 TArrayI s1(3);
477 s1[0] = 6;
478 s1[1] = 1;
479 s1[2] = 2;
480
481 TArrayI s2(3);
482 s2[0] = 3;
483 s2[1] = 4;
484 s2[2] = 5;
485
486 TArrayI inner(1);
487 inner[0] = 0;
488
489 TArrayI outer(1);
490 outer[0] = 1;
491
492 c.cd(i);
493 gPad->SetBorderMode(0);
494 gPad->SetTicks();
495 MHCamera *obj1 = (MHCamera*)cam.DrawCopy("hist");
496 obj1->SetDirectory(NULL);
497
498 c.cd(i+j);
499 // obj1->AddNotify(&evt);
500 obj1->SetPrettyPalette();
501 obj1->Draw();
502
503 if (fit != 0)
504 {
505 c.cd(i+2*j);
506 gPad->SetBorderMode(0);
507 gPad->SetTicks();
508 TProfile *obj2 = obj1->RadialProfile(Form("%s%s",obj1->GetName(),"_rad"));
509 obj2->SetDirectory(NULL);
510 obj2->Draw();
511 obj2->SetBit(kCanDelete);
512
513 TProfile *hprof[2];
514 hprof[0] = obj1->RadialProfileS(s0, inner,Form("%s%s",obj1->GetName(), "Inner"));
515 hprof[1] = obj1->RadialProfileS(s0, outer,Form("%s%s",obj1->GetName(), "Outer"));
516
517
518 for (Int_t k=0; k<2; k++)
519 {
520 Double_t min = cam.GetGeomCam().GetMinRadius(k);
521 Double_t max = cam.GetGeomCam().GetMaxRadius(k);
522
523 hprof[k]->SetLineColor(kRed+k);
524 hprof[k]->SetDirectory(0);
525 hprof[k]->SetBit(kCanDelete);
526 hprof[k]->Draw("same");
527 hprof[k]->Fit("pol1","Q","",min,max);
528 hprof[k]->GetFunction("pol1")->SetLineColor(kRed+k);
529 hprof[k]->GetFunction("pol1")->SetLineWidth(1);
530 }
531
532 gPad->Modified();
533 gPad->Update();
534
535 c.cd(i+3*j);
536 gPad->SetBorderMode(0);
537 gPad->SetTicks();
538 TH1D *obj3 = (TH1D*)obj1->Projection(Form("%s%s",obj1->GetName(),"_py"));
539 obj3->SetDirectory(NULL);
540// obj3->Sumw2();
541 obj3->Draw();
542 obj3->SetBit(kCanDelete);
543
544 gPad->Modified();
545 gPad->Update();
546
547 const Double_t min = obj3->GetBinCenter(obj3->GetXaxis()->GetFirst());
548 const Double_t max = obj3->GetBinCenter(obj3->GetXaxis()->GetLast());
549 const Double_t integ = obj3->Integral("width")/2.5066283;
550 const Double_t mean = obj3->GetMean();
551 const Double_t rms = obj3->GetRMS();
552 const Double_t width = max-min;
553
554 if (rms == 0. || width == 0. )
555 return;
556
557 switch (fit)
558 {
559 case 1:
560 TF1 *sgaus = new TF1("sgaus","gaus(0)",min,max);
561 sgaus->SetBit(kCanDelete);
562 sgaus->SetParNames("Area","#mu","#sigma");
563 sgaus->SetParameters(integ/rms,mean,rms);
564 sgaus->SetParLimits(0,0.,integ);
565 sgaus->SetParLimits(1,min,max);
566 sgaus->SetParLimits(2,0,width/1.5);
567 obj3->Fit("sgaus","QLR");
568 obj3->GetFunction("sgaus")->SetLineColor(kYellow);
569 break;
570
571 case 2:
572 TString dgausform = "([0]-[3])/[2]*exp(-0.5*(x-[1])*(x-[1])/[2]/[2])";
573 dgausform += "+[3]/[5]*exp(-0.5*(x-[4])*(x-[4])/[5]/[5])";
574 TF1 *dgaus = new TF1("dgaus",dgausform.Data(),min,max);
575 dgaus->SetBit(kCanDelete);
576 dgaus->SetParNames("A_{tot}","#mu_{1}","#sigma_{1}","A_{2}","#mu_{2}","#sigma_{2}");
577 dgaus->SetParameters(integ,(min+mean)/2.,width/4.,
578 integ/width/2.,(max+mean)/2.,width/4.);
579 // The left-sided Gauss
580 dgaus->SetParLimits(0,integ-1.5,integ+1.5);
581 dgaus->SetParLimits(1,min+(width/10.),mean);
582 dgaus->SetParLimits(2,0,width/2.);
583 // The right-sided Gauss
584 dgaus->SetParLimits(3,0,integ);
585 dgaus->SetParLimits(4,mean,max-(width/10.));
586 dgaus->SetParLimits(5,0,width/2.);
587 obj3->Fit("dgaus","QLRM");
588 obj3->GetFunction("dgaus")->SetLineColor(kYellow);
589 break;
590
591 case 3:
592 TString tgausform = "([0]-[3]-[6])/[2]*exp(-0.5*(x-[1])*(x-[1])/[2]/[2])";
593 tgausform += "+[3]/[5]*exp(-0.5*(x-[4])*(x-[4])/[5]/[5])";
594 tgausform += "+[6]/[8]*exp(-0.5*(x-[7])*(x-[7])/[8]/[8])";
595 TF1 *tgaus = new TF1("tgaus",tgausform.Data(),min,max);
596 tgaus->SetBit(kCanDelete);
597 tgaus->SetParNames("A_{tot}","#mu_{1}","#sigma_{1}",
598 "A_{2}","#mu_{2}","#sigma_{2}",
599 "A_{3}","#mu_{3}","#sigma_{3}");
600 tgaus->SetParameters(integ,(min+mean)/2,width/4.,
601 integ/width/3.,(max+mean)/2.,width/4.,
602 integ/width/3.,mean,width/2.);
603 // The left-sided Gauss
604 tgaus->SetParLimits(0,integ-1.5,integ+1.5);
605 tgaus->SetParLimits(1,min+(width/10.),mean);
606 tgaus->SetParLimits(2,width/15.,width/2.);
607 // The right-sided Gauss
608 tgaus->SetParLimits(3,0.,integ);
609 tgaus->SetParLimits(4,mean,max-(width/10.));
610 tgaus->SetParLimits(5,width/15.,width/2.);
611 // The Gauss describing the outliers
612 tgaus->SetParLimits(6,0.,integ);
613 tgaus->SetParLimits(7,min,max);
614 tgaus->SetParLimits(8,width/4.,width/1.5);
615 obj3->Fit("tgaus","QLRM");
616 obj3->GetFunction("tgaus")->SetLineColor(kYellow);
617 break;
618 case 4:
619 obj3->Fit("pol0","Q");
620 obj3->GetFunction("pol0")->SetLineColor(kYellow);
621 break;
622 case 9:
623 break;
624 default:
625 obj3->Fit("gaus","Q");
626 obj3->GetFunction("gaus")->SetLineColor(kYellow);
627 break;
628 }
629
630
631
632 // Just to get the right (maximum) binning
633 TH1D *half[4];
634 half[0] = (TH1D*)obj1->ProjectionS(s1, inner, "Sector 6-1-2 Inner");
635 half[1] = (TH1D*)obj1->ProjectionS(s2, inner, "Sector 3-4-5 Inner");
636 half[2] = (TH1D*)obj1->ProjectionS(s1, outer, "Sector 6-1-2 Outer");
637 half[3] = (TH1D*)obj1->ProjectionS(s2, outer, "Sector 3-4-5 Outer");
638
639 for (Int_t k=0; k<4; k++)
640 {
641 half[k]->SetLineColor(kRed+k);
642 half[k]->SetDirectory(0);
643 half[k]->SetBit(kCanDelete);
644 half[k]->Draw("same");
645 }
646
647 gPad->Modified();
648 gPad->Update();
649
650 }
651}
652
Note: See TracBrowser for help on using the repository browser.