source: trunk/MagicSoft/Mars/manalysisct1/MCT1PadSchweizer.cc@ 9029

Last change on this file since 9029 was 4457, checked in by tbretz, 20 years ago
*** empty log message ***
File size: 25.1 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): Robert Wagner, 10/2002 <mailto:magicsoft@rwagner.de>
19! Author(s): Wolfgang Wittek, 02/2003 <mailto:wittek@mppmu.mpg.de>
20!
21! Copyright: MAGIC Software Development, 2000-2003
22!
23!
24\* ======================================================================== */
25
26/////////////////////////////////////////////////////////////////////////////
27//
28// MCT1PadSchweizer
29//
30// This task applies padding such that for a given pixel and for a given
31// Theta bin the resulting distribution of the pedestal sigma is identical
32// to the distributions given by fHSigmaPixTheta and fHDiffPixTheta.
33//
34// The number of photons, its error and the pedestal sigmas are altered.
35// On average, the number of photons added is zero.
36//
37// The formulas used can be found in Thomas Schweizer's Thesis,
38// Section 2.2.1
39//
40// There are 2 options for the padding :
41//
42// 1) fPadFlag = 1 :
43// Generate first a Sigmabar using the 2D-histogram Sigmabar vs. Theta
44// (fHSigmaTheta). Then generate a pedestal sigma for each pixel using
45// the 3D-histogram Theta, pixel no., Sigma^2-Sigmabar^2
46// (fHDiffPixTheta).
47//
48// This is the preferred option as it takes into account the
49// correlations between the Sigma of a pixel and Sigmabar.
50//
51// 2) fPadFlag = 2 :
52// Generate a pedestal sigma for each pixel using the 3D-histogram
53// Theta, pixel no., Sigma (fHSigmaPixTheta).
54//
55//
56// The padding has to be done before the image cleaning because the
57// image cleaning depends on the pedestal sigmas.
58//
59// For random numbers gRandom is used.
60//
61// This implementation has been tested for CT1 data. For MAGIC some
62// modifications are necessary.
63//
64/////////////////////////////////////////////////////////////////////////////
65#include "MCT1PadSchweizer.h"
66
67#include <stdio.h>
68
69#include <TH1.h>
70#include <TH2.h>
71#include <TH3.h>
72#include <TRandom.h>
73#include <TCanvas.h>
74
75#include "MBinning.h"
76#include "MSigmabar.h"
77#include "MMcEvt.hxx"
78#include "MLog.h"
79#include "MLogManip.h"
80#include "MParList.h"
81#include "MGeomCam.h"
82
83#include "MCerPhotPix.h"
84#include "MCerPhotEvt.h"
85
86#include "MPedPhotCam.h"
87#include "MPedPhotPix.h"
88
89#include "MBlindPixels.h"
90
91ClassImp(MCT1PadSchweizer);
92
93using namespace std;
94
95// --------------------------------------------------------------------------
96//
97// Default constructor.
98//
99MCT1PadSchweizer::MCT1PadSchweizer(const char *name, const char *title)
100{
101 fName = name ? name : "MCT1PadSchweizer";
102 fTitle = title ? title : "Task for the padding (Schweizer)";
103
104 fHSigmaTheta = NULL;
105 fHSigmaPixTheta = NULL;
106 fHDiffPixTheta = NULL;
107 fHBlindPixIdTheta = NULL;
108 fHBlindPixNTheta = NULL;
109
110 fHSigmaPedestal = NULL;
111 fHPhotons = NULL;
112 fHNSB = NULL;
113}
114
115// --------------------------------------------------------------------------
116//
117// Destructor.
118//
119MCT1PadSchweizer::~MCT1PadSchweizer()
120{
121 if (fHSigmaPedestal != NULL) delete fHSigmaPedestal;
122 if (fHPhotons != NULL) delete fHPhotons;
123 if (fHNSB != NULL) delete fHNSB;
124}
125
126// --------------------------------------------------------------------------
127//
128// Set the references to the histograms to be used in the padding
129//
130// fHSigmaTheta 2D-histogram (Theta, sigmabar)
131// fHSigmaPixTheta 3D-hiostogram (Theta, pixel, sigma)
132// fHDiffPixTheta 3D-histogram (Theta, pixel, sigma^2-sigmabar^2)
133// fHBlindPixIdTheta 2D-histogram (Theta, blind pixel Id)
134// fHBlindPixNTheta 2D-histogram (Theta, no.of blind pixels )
135//
136//
137void MCT1PadSchweizer::SetHistograms(TH2D *hist2, TH3D *hist3, TH3D *hist3Diff,
138 TH2D *hist2Pix, TH2D *hist2PixN)
139{
140 fHSigmaTheta = hist2;
141 fHSigmaPixTheta = hist3;
142 fHDiffPixTheta = hist3Diff;
143 fHBlindPixIdTheta = hist2Pix;
144 fHBlindPixNTheta = hist2PixN;
145
146 fHSigmaTheta->SetDirectory(NULL);
147 fHSigmaPixTheta->SetDirectory(NULL);
148 fHDiffPixTheta->SetDirectory(NULL);
149 fHBlindPixIdTheta->SetDirectory(NULL);
150 fHBlindPixNTheta->SetDirectory(NULL);
151
152 Print();
153}
154
155// --------------------------------------------------------------------------
156//
157// Set the option for the padding
158//
159// There are 2 options for the padding :
160//
161// 1) fPadFlag = 1 :
162// Generate first a Sigmabar using the 2D-histogram Sigmabar vs. Theta
163// (fHSigmaTheta). Then generate a pedestal sigma for each pixel using
164// the 3D-histogram Theta, pixel no., Sigma^2-Sigmabar^2
165// (fHDiffPixTheta).
166//
167// This is the preferred option as it takes into account the
168// correlations between the Sigma of a pixel and Sigmabar.
169//
170// 2) fPadFlag = 2 :
171// Generate a pedestal sigma for each pixel using the 3D-histogram
172// Theta, pixel no., Sigma (fHSigmaPixTheta).
173//
174void MCT1PadSchweizer::SetPadFlag(Int_t padflag)
175{
176 fPadFlag = padflag;
177 *fLog << "MCT1PadSchweizer::SetPadFlag(); choose option " << fPadFlag << endl;
178}
179
180// --------------------------------------------------------------------------
181//
182// Set the pointers and prepare the histograms
183//
184Int_t MCT1PadSchweizer::PreProcess(MParList *pList)
185{
186 if ( !fHSigmaTheta || !fHSigmaPixTheta || !fHDiffPixTheta ||
187 !fHBlindPixIdTheta || !fHBlindPixNTheta)
188 {
189 *fLog << err << "At least one of the histograms needed for the padding is not defined ... aborting." << endl;
190 return kFALSE;
191 }
192
193 fMcEvt = (MMcEvt*)pList->FindObject("MMcEvt");
194 if (!fMcEvt)
195 {
196 *fLog << err << dbginf << "MMcEvt not found... aborting." << endl;
197 return kFALSE;
198 }
199
200 fPed = (MPedPhotCam*)pList->FindObject("MPedPhotCam");
201 if (!fPed)
202 {
203 *fLog << err << "MPedPhotCam not found... aborting." << endl;
204 return kFALSE;
205 }
206
207 fCam = (MGeomCam*)pList->FindObject("MGeomCam");
208 if (!fCam)
209 {
210 *fLog << err << "MGeomCam not found (no geometry information available)... aborting." << endl;
211 return kFALSE;
212 }
213
214 fEvt = (MCerPhotEvt*)pList->FindObject("MCerPhotEvt");
215 if (!fEvt)
216 {
217 *fLog << err << "MCerPhotEvt not found... aborting." << endl;
218 return kFALSE;
219 }
220
221 fSigmabar = (MSigmabar*)pList->FindCreateObj("MSigmabar");
222 if (!fSigmabar)
223 {
224 *fLog << err << "MSigmabar not found... aborting." << endl;
225 return kFALSE;
226 }
227
228 fBlinds = (MBlindPixels*)pList->FindCreateObj("MBlindPixels");
229 if (!fBlinds)
230 {
231 *fLog << err << "MBlindPixels not found... aborting." << endl;
232 return kFALSE;
233 }
234
235
236 //--------------------------------------------------------------------
237 // histograms for checking the padding
238 //
239 // plot pedestal sigmas
240 fHSigmaPedestal = new TH2D("SigPed","Sigma: after vs. before padding",
241 100, 0.0, 5.0, 100, 0.0, 5.0);
242 fHSigmaPedestal->SetXTitle("Pedestal sigma before padding");
243 fHSigmaPedestal->SetYTitle("Pedestal sigma after padding");
244
245 // plot no.of photons (before vs. after padding)
246 fHPhotons = new TH2D("Photons","Photons: after vs.before padding",
247 100, -10.0, 90.0, 100, -10, 90);
248 fHPhotons->SetXTitle("no.of photons before padding");
249 fHPhotons->SetYTitle("no.of photons after padding");
250
251 // plot of added NSB
252 fHNSB = new TH1D("NSB","Distribution of added NSB", 100, -10.0, 10.0);
253 fHNSB->SetXTitle("no.of added NSB photons");
254 fHNSB->SetYTitle("no.of pixels");
255
256
257 //--------------------------------------------------------------------
258
259 memset(fErrors, 0, sizeof(fErrors));
260
261 return kTRUE;
262}
263
264// --------------------------------------------------------------------------
265//
266// Do the Padding
267// idealy the events to be padded should have been generated without NSB
268//
269Int_t MCT1PadSchweizer::Process()
270{
271 //*fLog << "Entry MCT1PadSchweizer::Process();" << endl;
272
273 //------------------------------------------------
274 // add pixels to MCerPhotEvt which are not yet in;
275 // set their numnber of photons equal to zero
276
277 UInt_t imaxnumpix = fCam->GetNumPixels();
278
279 for (UInt_t i=0; i<imaxnumpix; i++)
280 {
281 Bool_t alreadythere = kFALSE;
282 UInt_t npix = fEvt->GetNumPixels();
283 for (UInt_t j=0; j<npix; j++)
284 {
285 MCerPhotPix &pix = (*fEvt)[j];
286 UInt_t id = pix.GetPixId();
287 if (i==id)
288 {
289 alreadythere = kTRUE;
290 break;
291 }
292 }
293 if (alreadythere)
294 continue;
295
296 fEvt->AddPixel(i, 0.0, (*fPed)[i].GetRms());
297 }
298
299
300
301 //-----------------------------------------
302 Int_t rc=0;
303
304 const UInt_t npix = fEvt->GetNumPixels();
305
306 //fSigmabar->Calc(*fCam, *fPed, *fEvt);
307 //*fLog << "before padding : " << endl;
308 //fSigmabar->Print("");
309
310
311 //$$$$$$$$$$$$$$$$$$$$$$$$$$
312 // to simulate the situation that before the padding the NSB and
313 // electronic noise are zero : set Sigma = 0 for all pixels
314 //for (UInt_t i=0; i<npix; i++)
315 //{
316 // MCerPhotPix &pix = fEvt->operator[](i);
317 // Int_t j = pix.GetPixId();
318
319 // MPedPhotPix &ppix = fPed->operator[](j);
320 // ppix.SetRms(0.0);
321 //}
322 //$$$$$$$$$$$$$$$$$$$$$$$$$$
323
324 //-------------------------------------------
325 // Calculate average sigma of the event
326 //
327 Double_t sigbarold = fSigmabar->Calc(*fCam, *fPed, *fEvt);
328 Double_t sigbarold2 = sigbarold*sigbarold;
329 //fSigmabar->Print("");
330
331 if (sigbarold > 0)
332 {
333 //*fLog << "MCT1PadSchweizer::Process(); sigmabar of event to be padded is > 0 : "
334 // << sigbarold << ". Stop event loop " << endl;
335 // input data should have sigmabar = 0; stop event loop
336
337 rc = 1;
338 fErrors[rc]++;
339 return kCONTINUE;
340 }
341
342 const Double_t theta = kRad2Deg*fMcEvt->GetTelescopeTheta();
343 // *fLog << "theta = " << theta << endl;
344
345
346 //-------------------------------------------
347 // for the current theta,
348 // generate blind pixels according to the histograms
349 // fHBlindPixNTheta and fHBlindPixIDTheta
350 //
351
352
353 Int_t binPix = fHBlindPixNTheta->GetXaxis()->FindBin(theta);
354
355 if ( binPix < 1 || binPix > fHBlindPixNTheta->GetNbinsX() )
356 {
357 //*fLog << "MCT1PadSchweizer::Process(); binNumber out of range : theta, binPix = "
358 // << theta << ", " << binPix << "; Skip event " << endl;
359 // event cannot be padded; skip event
360
361 rc = 2;
362 fErrors[rc]++;
363 return kCONTINUE;
364 }
365
366 // numBlind is the number of blind pixels in this event
367 TH1D *nblind;
368 UInt_t numBlind;
369
370 nblind = fHBlindPixNTheta->ProjectionY("", binPix, binPix, "");
371 if ( nblind->GetEntries() == 0.0 )
372 {
373 *fLog << "MCT1PadSchweizer::Process(); projection for Theta bin "
374 << binPix << " has no entries; Skip event " << endl;
375 // event cannot be padded; skip event
376 delete nblind;
377
378 rc = 7;
379 fErrors[rc]++;
380 return kCONTINUE;
381 }
382 else
383 {
384 numBlind = (Int_t) (nblind->GetRandom()+0.5);
385 }
386 delete nblind;
387
388
389 // throw the Id of numBlind different pixels in this event
390 TH1D *hblind;
391 UInt_t idBlind;
392 UInt_t listId[npix];
393 UInt_t nlist = 0;
394 Bool_t equal;
395
396 hblind = fHBlindPixIdTheta->ProjectionY("", binPix, binPix, "");
397 if ( hblind->GetEntries() > 0.0 )
398 for (UInt_t i=0; i<numBlind; i++)
399 {
400 while(1)
401 {
402 idBlind = (Int_t) (hblind->GetRandom()+0.5);
403 equal = kFALSE;
404 for (UInt_t j=0; j<nlist; j++)
405 if (idBlind == listId[j])
406 {
407 equal = kTRUE;
408 break;
409 }
410 if (!equal) break;
411 }
412 listId[nlist] = idBlind;
413 nlist++;
414
415 fBlinds->SetPixelBlind(idBlind);
416 //*fLog << "idBlind = " << idBlind << endl;
417 }
418 fBlinds->SetReadyToSave();
419
420 delete hblind;
421
422
423 //-------------------------------------------
424 // for the current theta,
425 // generate a sigmabar according to the histogram fHSigmaTheta
426 //
427 Double_t sigmabar=0;
428 Int_t binNumber = fHSigmaTheta->GetXaxis()->FindBin(theta);
429
430 if (binPix != binNumber)
431 {
432 cout << "The binnings of the 2 histograms are not identical; aborting"
433 << endl;
434 return kERROR;
435 }
436
437 TH1D *hsigma;
438
439 hsigma = fHSigmaTheta->ProjectionY("", binNumber, binNumber, "");
440 if ( hsigma->GetEntries() == 0.0 )
441 {
442 *fLog << "MCT1PadSchweizer::Process(); projection for Theta bin "
443 << binNumber << " has no entries; Skip event " << endl;
444 // event cannot be padded; skip event
445 delete hsigma;
446
447 rc = 3;
448 fErrors[rc]++;
449 return kCONTINUE;
450 }
451 else
452 {
453 sigmabar = hsigma->GetRandom();
454 //*fLog << "Theta, bin number = " << theta << ", " << binNumber // << ", sigmabar = " << sigmabar << endl
455 }
456 delete hsigma;
457
458 const Double_t sigmabar2 = sigmabar*sigmabar;
459
460 //-------------------------------------------
461
462 //*fLog << "MCT1PadSchweizer::Process(); sigbarold, sigmabar = "
463 // << sigbarold << ", "<< sigmabar << endl;
464
465 // Skip event if target sigmabar is <= sigbarold
466 if (sigmabar <= sigbarold)
467 {
468 *fLog << "MCT1PadSchweizer::Process(); target sigmabar is less than sigbarold : "
469 << sigmabar << ", " << sigbarold << ", Skip event" << endl;
470
471 rc = 4;
472 fErrors[rc]++;
473 return kCONTINUE;
474 }
475
476
477 //-------------------------------------------
478 //
479 // Calculate average number of NSB photons to be added (lambdabar)
480 // from the value of sigmabar,
481 // - making assumptions about the average electronic noise (elNoise2) and
482 // - using a fixed value (F2excess) for the excess noise factor
483
484 Double_t elNoise2; // [photons]
485 Double_t F2excess = 1.3;
486 Double_t lambdabar; // [photons]
487
488
489
490 Int_t binTheta = fHDiffPixTheta->GetXaxis()->FindBin(theta);
491 if (binTheta != binNumber)
492 {
493 cout << "The binnings of the 2 histograms are not identical; aborting"
494 << endl;
495 return kERROR;
496 }
497
498 // Get RMS of (Sigma^2-sigmabar^2) in this Theta bin.
499 // The average electronic noise (to be added) has to be well above this RMS,
500 // otherwise the electronic noise of an individual pixel (elNoise2Pix)
501 // may become negative
502
503 TH1D *hnoise = fHDiffPixTheta->ProjectionZ("", binTheta, binTheta,
504 0, 9999, "");
505 Double_t RMS = hnoise->GetRMS(1);
506 delete hnoise;
507
508 elNoise2 = TMath::Min(RMS, sigmabar2 - sigbarold2);
509 //*fLog << "elNoise2 = " << elNoise2 << endl;
510
511 lambdabar = (sigmabar2 - sigbarold2 - elNoise2) / F2excess; // [photons]
512
513 // This value of lambdabar is the same for all pixels;
514 // note that lambdabar is normalized to the area of pixel 0
515
516 //---------- start loop over pixels ---------------------------------
517 // do the padding for each pixel
518 //
519 // pad only pixels - which are used (before image cleaning)
520 //
521 Double_t sig = 0;
522 Double_t sigma2 = 0;
523 Double_t diff = 0;
524 Double_t addSig2 = 0;
525 Double_t elNoise2Pix = 0;
526
527
528 for (UInt_t i=0; i<npix; i++)
529 {
530 MCerPhotPix &pix = (*fEvt)[i];
531 if ( !pix.IsPixelUsed() )
532 continue;
533
534 //if ( pix.GetNumPhotons() == 0.0)
535 //{
536 // *fLog << "MCT1PadSchweizer::Process(); no.of photons is 0 for used pixel"
537 // << endl;
538 // continue;
539 //}
540
541 Int_t j = pix.GetPixId();
542
543 // GetPixRatio returns (area of pixel 0 / area of current pixel)
544 Double_t ratioArea = 1.0 / fCam->GetPixRatio(j);
545
546 MPedPhotPix &ppix = (*fPed)[j];
547 Double_t oldsigma = ppix.GetRms();
548 Double_t oldsigma2 = oldsigma*oldsigma;
549
550 //---------------------------------
551 // throw the Sigma for this pixel
552 //
553 Int_t binPixel = fHDiffPixTheta->GetYaxis()->FindBin( (Double_t)j );
554
555 Int_t count;
556 Bool_t ok;
557
558 TH1D *hdiff;
559 TH1D *hsig;
560
561 switch (fPadFlag)
562 {
563 case 1 :
564 // throw the Sigma for this pixel from the distribution fHDiffPixTheta
565
566 hdiff = fHDiffPixTheta->ProjectionZ("", binTheta, binTheta,
567 binPixel, binPixel, "");
568 if ( hdiff->GetEntries() == 0 )
569 {
570 *fLog << "MCT1PadSchweizer::Process(); projection for Theta bin "
571 << binTheta << " and pixel bin " << binPixel
572 << " has no entries; aborting " << endl;
573 delete hdiff;
574
575 rc = 5;
576 fErrors[rc]++;
577 return kCONTINUE;
578 }
579
580 count = 0;
581 ok = kFALSE;
582 for (Int_t m=0; m<20; m++)
583 {
584 count += 1;
585 diff = hdiff->GetRandom();
586 // the following condition ensures that elNoise2Pix > 0.0
587
588 if ( (diff + sigmabar2 - oldsigma2/ratioArea
589 - lambdabar*F2excess) > 0.0 )
590 {
591 ok = kTRUE;
592 break;
593 }
594 }
595 if (!ok)
596 {
597
598 *fLog << "theta, j, count, sigmabar, diff = " << theta << ", "
599 << j << ", " << count << ", " << sigmabar << ", "
600 << diff << endl;
601 diff = lambdabar*F2excess + oldsigma2/ratioArea - sigmabar2;
602 }
603 delete hdiff;
604 sigma2 = diff + sigmabar2;
605 break;
606
607 case 2 :
608 // throw the Sigma for this pixel from the distribution fHSigmaPixTheta
609
610 hsig = fHSigmaPixTheta->ProjectionZ("", binTheta, binTheta,
611 binPixel, binPixel, "");
612 if ( hsig->GetEntries() == 0 )
613 {
614 *fLog << "MCT1PadSchweizer::Process(); projection for Theta bin "
615 << binTheta << " and pixel bin " << binPixel
616 << " has no entries; aborting " << endl;
617 delete hsig;
618
619 rc = 6;
620 fErrors[rc]++;
621 return kCONTINUE;
622 }
623
624 count = 0;
625 ok = kFALSE;
626 for (Int_t m=0; m<20; m++)
627 {
628 count += 1;
629
630 sig = hsig->GetRandom();
631 sigma2 = sig*sig/ratioArea;
632 // the following condition ensures that elNoise2Pix > 0.0
633
634 if ( (sigma2-oldsigma2/ratioArea-lambdabar*F2excess) > 0.0 )
635 {
636 ok = kTRUE;
637 break;
638 }
639 }
640 if (!ok)
641 {
642
643 *fLog << "theta, j, count, sigmabar, sig = " << theta << ", "
644 << j << ", " << count << ", " << sigmabar << ", "
645 << sig << endl;
646 sigma2 = lambdabar*F2excess + oldsigma2/ratioArea;
647 }
648 delete hsig;
649 break;
650 }
651
652 //---------------------------------
653 // get the additional sigma^2 for this pixel (due to the padding)
654
655 addSig2 = sigma2*ratioArea - oldsigma2;
656
657
658 //---------------------------------
659 // get the additional electronic noise for this pixel
660
661 elNoise2Pix = addSig2 - lambdabar*F2excess*ratioArea;
662
663
664 //---------------------------------
665 // throw actual number of additional NSB photons (NSB)
666 // and its RMS (sigmaNSB)
667
668 Double_t NSB0 = gRandom->Poisson(lambdabar*ratioArea);
669 Double_t arg = NSB0*(F2excess-1.0) + elNoise2Pix;
670 Double_t sigmaNSB0;
671
672 if (arg >= 0)
673 {
674 sigmaNSB0 = sqrt( arg );
675 }
676 else
677 {
678 *fLog << "MCT1PadSchweizer::Process(); argument of sqrt < 0 : "
679 << arg << endl;
680 sigmaNSB0 = 0.0000001;
681 }
682
683
684 //---------------------------------
685 // smear NSB0 according to sigmaNSB0
686 // and subtract lambdabar because of AC coupling
687
688 Double_t NSB = gRandom->Gaus(NSB0, sigmaNSB0) - lambdabar*ratioArea;
689
690 //---------------------------------
691
692 // add additional NSB to the number of photons
693 Double_t oldphotons = pix.GetNumPhotons();
694 Double_t newphotons = oldphotons + NSB;
695 pix.SetNumPhotons(newphotons);
696
697
698 fHNSB->Fill( NSB/sqrt(ratioArea) );
699 fHPhotons->Fill( oldphotons/sqrt(ratioArea), newphotons/sqrt(ratioArea) );
700
701
702 // error: add sigma of padded noise quadratically
703 Double_t olderror = pix.GetErrorPhot();
704 Double_t newerror = sqrt(olderror*olderror + addSig2);
705 pix.SetErrorPhot(newerror);
706
707
708 Double_t newsigma = sqrt(oldsigma2 + addSig2);
709 ppix.SetRms(newsigma);
710
711 fHSigmaPedestal->Fill(oldsigma, newsigma);
712 }
713 //---------- end of loop over pixels ---------------------------------
714
715 // Calculate sigmabar again and crosscheck
716
717
718 //fSigmabar->Calc(*fCam, *fPed, *fEvt);
719 //*fLog << "after padding : " << endl;
720 //fSigmabar->Print("");
721
722
723 //*fLog << "Exit MCT1PadSchweizer::Process();" << endl;
724
725 rc = 0;
726 fErrors[rc]++;
727
728 return kTRUE;
729
730}
731
732// --------------------------------------------------------------------------
733//
734//
735Int_t MCT1PadSchweizer::PostProcess()
736{
737 if (GetNumExecutions() != 0)
738 {
739
740 *fLog << inf << endl;
741 *fLog << GetDescriptor() << " execution statistics:" << endl;
742 *fLog << dec << setfill(' ');
743 *fLog << " " << setw(7) << fErrors[1] << " (" << setw(3)
744 << (int)(fErrors[1]*100/GetNumExecutions())
745 << "%) Evts skipped due to: Sigmabar_old > 0" << endl;
746
747 *fLog << " " << setw(7) << fErrors[2] << " (" << setw(3)
748 << (int)(fErrors[2]*100/GetNumExecutions())
749 << "%) Evts skipped due to: Zenith angle out of range" << endl;
750
751 *fLog << " " << setw(7) << fErrors[3] << " (" << setw(3)
752 << (int)(fErrors[3]*100/GetNumExecutions())
753 << "%) Evts skipped due to: No data for generating Sigmabar" << endl;
754
755 *fLog << " " << setw(7) << fErrors[4] << " (" << setw(3)
756 << (int)(fErrors[4]*100/GetNumExecutions())
757 << "%) Evts skipped due to: Target sigma <= Sigmabar_old" << endl;
758
759 *fLog << " " << setw(7) << fErrors[5] << " (" << setw(3)
760 << (int)(fErrors[5]*100/GetNumExecutions())
761 << "%) Evts skipped due to: No data for generating Sigma^2-Sigmabar^2" << endl;
762
763 *fLog << " " << setw(7) << fErrors[6] << " (" << setw(3)
764 << (int)(fErrors[6]*100/GetNumExecutions())
765 << "%) Evts skipped due to: No data for generating Sigma" << endl;
766
767 *fLog << " " << setw(7) << fErrors[7] << " (" << setw(3)
768 << (int)(fErrors[7]*100/GetNumExecutions())
769 << "%) Evts skipped due to: No data for generating Blind pixels" << endl;
770
771 *fLog << " " << fErrors[0] << " ("
772 << (int)(fErrors[0]*100/GetNumExecutions())
773 << "%) Evts survived the padding!" << endl;
774 *fLog << endl;
775
776 }
777
778 //---------------------------------------------------------------
779 TCanvas &c = *(MH::MakeDefCanvas("PadSchweizer", "", 900, 1200));
780 c.Divide(3, 4);
781 gROOT->SetSelectedPad(NULL);
782
783 c.cd(1);
784 fHNSB->SetDirectory(NULL);
785 fHNSB->DrawCopy();
786 fHNSB->SetBit(kCanDelete);
787
788 c.cd(2);
789 fHSigmaPedestal->SetDirectory(NULL);
790 fHSigmaPedestal->DrawCopy();
791 fHSigmaPedestal->SetBit(kCanDelete);
792
793 c.cd(3);
794 fHPhotons->SetDirectory(NULL);
795 fHPhotons->DrawCopy();
796 fHPhotons->SetBit(kCanDelete);
797
798 //--------------------------------------------------------------------
799
800
801 c.cd(4);
802 fHSigmaTheta->SetDirectory(NULL);
803 fHSigmaTheta->SetTitle("(Input) 2D : Sigmabar, \\Theta");
804 fHSigmaTheta->DrawCopy();
805 fHSigmaTheta->SetBit(kCanDelete);
806
807 //--------------------------------------------------------------------
808
809
810 c.cd(7);
811 fHBlindPixNTheta->SetDirectory(NULL);
812 fHBlindPixNTheta->SetTitle("(Input) 2D : no.of blind pixels, \\Theta");
813 fHBlindPixNTheta->DrawCopy();
814 fHBlindPixNTheta->SetBit(kCanDelete);
815
816 //--------------------------------------------------------------------
817
818
819 c.cd(10);
820 fHBlindPixIdTheta->SetDirectory(NULL);
821 fHBlindPixIdTheta->SetTitle("(Input) 2D : blind pixel Id, \\Theta");
822 fHBlindPixIdTheta->DrawCopy();
823 fHBlindPixIdTheta->SetBit(kCanDelete);
824
825
826 //--------------------------------------------------------------------
827 // draw the 3D histogram (input): Theta, pixel, Sigma^2-Sigmabar^2
828
829 c.cd(5);
830 TH2D *l1;
831 l1 = (TH2D*) ((TH3*)fHDiffPixTheta)->Project3D("zx");
832 l1->SetDirectory(NULL);
833 l1->SetTitle("(Input) Sigma^2-Sigmabar^2 vs. \\Theta (all pixels)");
834 l1->SetXTitle("\\Theta [\\circ]");
835 l1->SetYTitle("Sigma^2-Sigmabar^2");
836
837 l1->DrawCopy("box");
838 l1->SetBit(kCanDelete);;
839
840 c.cd(8);
841 TH2D *l2;
842 l2 = (TH2D*) ((TH3*)fHDiffPixTheta)->Project3D("zy");
843 l2->SetDirectory(NULL);
844 l2->SetTitle("(Input) Sigma^2-Sigmabar^2 vs. pixel number (all \\Theta)");
845 l2->SetXTitle("pixel");
846 l2->SetYTitle("Sigma^2-Sigmabar^2");
847
848 l2->DrawCopy("box");
849 l2->SetBit(kCanDelete);;
850
851 //--------------------------------------------------------------------
852 // draw the 3D histogram (input): Theta, pixel, Sigma
853
854 c.cd(6);
855 TH2D *k1;
856 k1 = (TH2D*) ((TH3*)fHSigmaPixTheta)->Project3D("zx");
857 k1->SetDirectory(NULL);
858 k1->SetTitle("(Input) Sigma vs. \\Theta (all pixels)");
859 k1->SetXTitle("\\Theta [\\circ]");
860 k1->SetYTitle("Sigma");
861
862 k1->DrawCopy("box");
863 k1->SetBit(kCanDelete);
864
865 c.cd(9);
866 TH2D *k2;
867 k2 = (TH2D*) ((TH3*)fHSigmaPixTheta)->Project3D("zy");
868 k2->SetDirectory(NULL);
869 k2->SetTitle("(Input) Sigma vs. pixel number (all \\Theta)");
870 k2->SetXTitle("pixel");
871 k2->SetYTitle("Sigma");
872
873 k2->DrawCopy("box");
874 k2->SetBit(kCanDelete);;
875
876
877 //--------------------------------------------------------------------
878
879
880 return kTRUE;
881}
882
883// --------------------------------------------------------------------------
884
885
886
887
888
889
890
891
892
893
894
895
896
897
Note: See TracBrowser for help on using the repository browser.