Changeset 2128 for trunk/MagicSoft/Mars
- Timestamp:
- 05/21/03 12:21:58 (22 years ago)
- Location:
- trunk/MagicSoft/Mars
- Files:
-
- 7 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/MagicSoft/Mars/Changelog
r2127 r2128 1 1 -*-*- END OF LINE -*-*- 2 3 2003/05/21: Wolfgang Wittek 4 5 * mhist/MHBlindPixels.[h,cc] 6 - change 1D histogram into 2D histogram (pixel Id vs. Theta) 7 - add 2D histogram : no.of blind pixels vs. Theta 8 9 * mhist/MHSigmaTheta.cc 10 - correct "BinningPix" 11 12 * manalysis/MPadSchweizer.[h,cc] 13 - add simulation of blind pixels 14 15 * mhist/MHMatrix.cc 16 - in DefRefMatrix : allow variable bin size for 'hth' and 'hthd' 17 18 19 2 20 2003/05/20: Oscar Blanch Bigas 3 21 … … 50 68 * manalysis/MFiltercutsCalc.[h,cc]: 51 69 - added 52 53 70 54 71 -
trunk/MagicSoft/Mars/manalysis/MPadSchweizer.cc
r2070 r2128 86 86 #include "MPedestalCam.h" 87 87 #include "MPedestalPix.h" 88 #include "MBlindPixels.h" 88 89 89 90 ClassImp(MPadSchweizer); … … 101 102 fHSigmaPixTheta = NULL; 102 103 fHDiffPixTheta = NULL; 104 fHBlindPixIdTheta = NULL; 105 fHBlindPixNTheta = NULL; 103 106 104 107 fHSigmaPedestal = NULL; … … 125 128 // fHSigmaPixTheta 3D-hiostogram (Theta, pixel, sigma) 126 129 // fHDiffPixTheta 3D-histogram (Theta, pixel, sigma^2-sigmabar^2) 127 // 128 // 129 void MPadSchweizer::SetHistograms(TH2D *hist2, TH3D *hist3, TH3D *hist3Diff) 130 // fHBlindPixIdTheta 2D-histogram (Theta, blind pixel Id) 131 // fHBlindPixNTheta 2D-histogram (Theta, no.of blind pixels ) 132 // 133 // 134 void MPadSchweizer::SetHistograms(TH2D *hist2, TH3D *hist3, TH3D *hist3Diff, 135 TH2D *hist2Pix, TH2D *hist2PixN) 130 136 { 131 137 fHSigmaTheta = hist2; 132 138 fHSigmaPixTheta = hist3; 133 139 fHDiffPixTheta = hist3Diff; 140 fHBlindPixIdTheta = hist2Pix; 141 fHBlindPixNTheta = hist2PixN; 134 142 135 143 fHSigmaTheta->SetDirectory(NULL); 136 144 fHSigmaPixTheta->SetDirectory(NULL); 137 145 fHDiffPixTheta->SetDirectory(NULL); 146 fHBlindPixIdTheta->SetDirectory(NULL); 147 fHBlindPixNTheta->SetDirectory(NULL); 138 148 139 149 Print(); … … 171 181 Bool_t MPadSchweizer::PreProcess(MParList *pList) 172 182 { 173 if ( !fHSigmaTheta || !fHSigmaPixTheta || !fHDiffPixTheta) 183 if ( !fHSigmaTheta || !fHSigmaPixTheta || !fHDiffPixTheta || 184 !fHBlindPixIdTheta || !fHBlindPixNTheta) 174 185 { 175 186 *fLog << err << "At least one of the histograms needed for the padding is not defined ... aborting." << endl; … … 190 201 return kFALSE; 191 202 } 192 203 193 204 fCam = (MGeomCam*)pList->FindObject("MGeomCam"); 194 205 if (!fCam) … … 211 222 return kFALSE; 212 223 } 224 225 fBlinds = (MBlindPixels*)pList->FindCreateObj("MBlindPixels"); 226 if (!fBlinds) 227 { 228 *fLog << err << "MBlindPixels not found... aborting." << endl; 229 return kFALSE; 230 } 213 231 214 232 … … 296 314 //------------------------------------------- 297 315 // for the current theta, 316 // generate blind pixels according to the histograms 317 // fHBlindPixNTheta and fHBlindPixIDTheta 318 // 319 320 321 Int_t binPix = fHBlindPixNTheta->GetXaxis()->FindBin(theta); 322 323 if ( binPix < 1 || binPix > fHBlindPixNTheta->GetNbinsX() ) 324 { 325 //*fLog << "MPadSchweizer::Process(); binNumber out of range : theta, binPix = " 326 // << theta << ", " << binPix << "; Skip event " << endl; 327 // event cannot be padded; skip event 328 329 rc = 2; 330 fErrors[rc]++; 331 return kCONTINUE; 332 } 333 334 // numBlind is the number of blind pixels in this event 335 TH1D *nblind; 336 UInt_t numBlind; 337 338 nblind = fHBlindPixNTheta->ProjectionY("", binPix, binPix, ""); 339 if ( nblind->GetEntries() == 0.0 ) 340 { 341 *fLog << "MPadSchweizer::Process(); projection for Theta bin " 342 << binPix << " has no entries; Skip event " << endl; 343 // event cannot be padded; skip event 344 delete nblind; 345 346 rc = 7; 347 fErrors[rc]++; 348 return kCONTINUE; 349 } 350 else 351 { 352 numBlind = (Int_t) (nblind->GetRandom()+0.5); 353 354 //*fLog << "numBlind = " << numBlind << endl; 355 } 356 delete nblind; 357 358 359 // throw the Id of numBlind different pixels in this event 360 TH1D *hblind; 361 UInt_t idBlind; 362 UInt_t listId[npix]; 363 UInt_t nlist = 0; 364 Bool_t equal; 365 366 hblind = fHBlindPixIdTheta->ProjectionY("", binPix, binPix, ""); 367 if ( hblind->GetEntries() > 0.0 ) 368 for (UInt_t i=0; i<numBlind; i++) 369 { 370 while(1) 371 { 372 idBlind = (Int_t) (hblind->GetRandom()+0.5); 373 equal = kFALSE; 374 for (UInt_t j=0; j<nlist; j++) 375 if (idBlind == listId[j]) 376 { 377 equal = kTRUE; 378 break; 379 } 380 if (!equal) break; 381 } 382 listId[nlist] = idBlind; 383 nlist++; 384 385 fBlinds->SetPixelBlind(idBlind); 386 //*fLog << "idBlind = " << idBlind << endl; 387 } 388 delete hblind; 389 390 391 //------------------------------------------- 392 // for the current theta, 298 393 // generate a sigmabar according to the histogram fHSigmaTheta 299 394 // … … 301 396 Int_t binNumber = fHSigmaTheta->GetXaxis()->FindBin(theta); 302 397 398 if (binPix != binNumber) 399 { 400 cout << "The binnings of the 2 histograms are not identical; aborting" 401 << endl; 402 return kERROR; 403 } 404 303 405 TH1D *hsigma; 304 406 305 if ( binNumber < 1 || binNumber > fHSigmaTheta->GetNbinsX() ) 407 hsigma = fHSigmaTheta->ProjectionY("", binNumber, binNumber, ""); 408 if ( hsigma->GetEntries() == 0.0 ) 306 409 { 307 //*fLog << "MPadSchweizer::Process(); binNumber out of range : theta, binNumber = "308 // << theta << ", " << binNumber << ";Skip event " << endl;410 *fLog << "MPadSchweizer::Process(); projection for Theta bin " 411 << binNumber << " has no entries; Skip event " << endl; 309 412 // event cannot be padded; skip event 310 311 rc = 2; 413 delete hsigma; 414 415 rc = 3; 312 416 fErrors[rc]++; 313 417 return kCONTINUE; … … 315 419 else 316 420 { 317 hsigma = fHSigmaTheta->ProjectionY("", binNumber, binNumber, ""); 318 if ( hsigma->GetEntries() == 0.0 ) 319 { 320 *fLog << "MPadSchweizer::Process(); projection for Theta bin " 321 << binNumber << " has no entries; Skip event " << endl; 322 // event cannot be padded; skip event 323 delete hsigma; 324 325 rc = 3; 326 fErrors[rc]++; 327 return kCONTINUE; 328 } 329 else 330 { 331 sigmabar = hsigma->GetRandom(); 332 333 //*fLog << "Theta, bin number = " << theta << ", " << binNumber 334 // << ", sigmabar = " << sigmabar << endl; 335 } 336 delete hsigma; 337 } 421 sigmabar = hsigma->GetRandom(); 422 //*fLog << "Theta, bin number = " << theta << ", " << binNumber // << ", sigmabar = " << sigmabar << endl 423 } 424 delete hsigma; 425 338 426 const Double_t sigmabar2 = sigmabar*sigmabar; 339 427 … … 644 732 << "%) Evts skipped due to: No data for generating Sigma" << endl; 645 733 734 *fLog << " " << setw(7) << fErrors[7] << " (" << setw(3) 735 << (int)(fErrors[7]*100/GetNumExecutions()) 736 << "%) Evts skipped due to: No data for generating Blind pixels" << endl; 737 646 738 *fLog << " " << fErrors[0] << " (" 647 739 << (int)(fErrors[0]*100/GetNumExecutions()) -
trunk/MagicSoft/Mars/manalysis/MPadSchweizer.h
r2021 r2128 20 20 class MSigmabar; 21 21 class MParList; 22 class MBlindPixels; 22 23 23 24 class MPadSchweizer : public MTask … … 29 30 MMcEvt *fMcEvt; 30 31 MPedestalCam *fPed; 32 MBlindPixels *fBlinds; 31 33 32 34 Int_t fPadFlag; … … 34 36 Int_t fGroup; 35 37 36 Int_t fErrors[ 7];38 Int_t fErrors[8]; 37 39 38 40 // plots used for the padding 41 TH2D *fHBlindPixIdTheta; // 2D-histogram (blind pixel Id vs. Theta) 42 TH2D *fHBlindPixNTheta; // 2D-histogram (no.of blind pixels vs. Theta) 39 43 TH2D *fHSigmaTheta; // 2D-histogram (sigmabar vs. Theta) 40 44 TH3D *fHSigmaPixTheta; // 3D-histogram (Theta, pixel, sigma) … … 53 57 ~MPadSchweizer(); 54 58 55 void SetHistograms(TH2D *hist2, TH3D *hist3, TH3D *hist3Diff); 59 void SetHistograms(TH2D *hist2, TH3D *hist3, TH3D *hist3Diff, 60 TH2D *hist2Pix, TH2D *hist2PixN); 56 61 57 62 Bool_t PreProcess(MParList *pList); -
trunk/MagicSoft/Mars/mhist/MHBlindPixels.cc
r2112 r2128 1 1 2 /* ======================================================================== *\ 2 3 ! … … 32 33 #include <TCanvas.h> 33 34 35 #include "MMcEvt.hxx" 34 36 #include "MBlindPixels.h" 37 #include "MPedestalCam.h" 38 #include "MParList.h" 39 #include "MBinning.h" 40 41 #include "MLog.h" 42 #include "MLogManip.h" 35 43 36 44 ClassImp(MHBlindPixels); … … 41 49 // 42 50 MHBlindPixels::MHBlindPixels(const char *name, const char *title) 43 : fHist(fName, fTitle, 577, -.5, 577-.5)44 51 { 45 52 fName = name ? name : "MHBlindPixels"; 46 fTitle = title ? title : "Histogram for Blind Pixels ";53 fTitle = title ? title : "Histogram for Blind Pixels vs. Theta"; 47 54 48 55 // - we initialize the histogram 49 // - we have to give dif erent names for the diferent histograms because56 // - we have to give different names for the different histograms because 50 57 // root don't allow us to have diferent histograms with the same name 51 58 52 fHist.SetName("1D-BlindPixels"); 53 fHist.SetTitle(fTitle); 59 fBlindId.SetName("2D-IdBlindPixels"); 60 fBlindId.SetTitle("2D-IdBlindPixels"); 61 fBlindId.SetDirectory(NULL); 62 fBlindId.SetXTitle("\\Theta [\\circ]"); 63 fBlindId.SetYTitle("pixel Id"); 54 64 55 fHist.SetDirectory(NULL); 65 fBlindN.SetName("2D-NBlindPixels"); 66 fBlindN.SetTitle("2D-NBlindPixels"); 67 fBlindN.SetDirectory(NULL); 68 fBlindN.SetXTitle("\\Theta [\\circ]"); 69 fBlindN.SetYTitle("number of blind pixels"); 70 } 56 71 57 fHist.SetXTitle("Id"); 58 fHist.SetYTitle("Counts"); 72 // -------------------------------------------------------------------------- 73 // 74 // Set the binnings and prepare the filling of the histogram 75 // 76 Bool_t MHBlindPixels::SetupFill(const MParList *plist) 77 { 78 fMcEvt = (MMcEvt*)plist->FindObject("MMcEvt"); 79 if (!fMcEvt) 80 { 81 *fLog << err << "MMcEvt not found... aborting." << endl; 82 return kFALSE; 83 } 84 85 fPed = (MPedestalCam*)plist->FindObject("MPedestalCam"); 86 if (!fPed) 87 { 88 *fLog << err << "MPedestalCam not found... aborting." << endl; 89 return kFALSE; 90 } 91 92 93 // Get Theta Binning 94 MBinning* binstheta = (MBinning*)plist->FindObject("BinningTheta", "MBinning"); 95 if (!binstheta) 96 { 97 *fLog << err << "Object 'BinningTheta' [MBinning] not found... aborting" << endl; 98 return kFALSE; 99 } 100 101 // Get binning for pixel number 102 const UInt_t npix1 = fPed->GetSize()+1; 103 104 MBinning binspix("BinningPixel"); 105 binspix.SetEdges(npix1, -0.5, npix1-0.5); 106 107 // Set binnings in histograms 108 SetBinning(&fBlindId, binstheta, &binspix); 109 SetBinning(&fBlindN, binstheta, &binspix); 110 111 return kTRUE; 59 112 } 60 113 … … 68 121 pad->SetBorderMode(0); 69 122 70 fHist.Draw(option); 123 pad->Divide(2,2); 124 125 TH1D *h; 126 127 pad->cd(1); 128 fBlindId.Draw(option); 129 130 pad->cd(2); 131 fBlindN.Draw(option); 132 133 pad->cd(3); 134 gPad->SetBorderMode(0); 135 h = ((TH2*)&fBlindId)->ProjectionY("ProjY-pixId", -1, 9999, ""); 136 h->SetDirectory(NULL); 137 h->SetTitle("Distribution of blind pixel Id"); 138 h->SetXTitle("Id of blind pixel"); 139 h->SetYTitle("No. of events"); 140 h->Draw(option); 141 h->SetBit(kCanDelete); 142 143 pad->cd(4); 144 gPad->SetBorderMode(0); 145 h = ((TH2*)&fBlindN)->ProjectionY("ProjY-pixN", -1, 9999, ""); 146 h->SetDirectory(NULL); 147 h->SetTitle("Distribution of no.of blind pixels"); 148 h->SetXTitle("No. of blind pixels"); 149 h->SetYTitle("No. of events"); 150 h->Draw(option); 151 h->SetBit(kCanDelete); 71 152 72 153 pad->Modified(); … … 79 160 return kFALSE; 80 161 162 Double_t theta = fMcEvt->GetTelescopeTheta()*kRad2Deg; 81 163 const MBlindPixels &bp = *(MBlindPixels*)par; 82 164 83 165 // FIXME: Slow. 84 for (int i=0; i<577; i++) 166 const UInt_t npix = fPed->GetSize(); 167 168 UInt_t nb = 0; 169 for (UInt_t i=0; i<npix; i++) 170 { 85 171 if (bp.IsBlind(i)) 86 fHist.Fill(i, w); 172 { 173 fBlindId.Fill(theta, i, w); 174 nb++; 175 } 176 } 177 fBlindN.Fill(theta, nb, w); 87 178 88 179 return kTRUE; 89 180 } 181 182 183 184 185 186 187 188 189 190 191 192 -
trunk/MagicSoft/Mars/mhist/MHBlindPixels.h
r2043 r2128 5 5 #include "MH.h" 6 6 #endif 7 #ifndef ROOT_TH 18 #include <TH 1.h>7 #ifndef ROOT_TH2 8 #include <TH2.h> 9 9 #endif 10 11 class MPedestalCam; 12 class MMcEvt; 13 class MParList; 14 10 15 11 16 class MHBlindPixels : public MH 12 17 { 13 18 private: 14 TH1D fHist; // 19 MPedestalCam *fPed; //! 20 MMcEvt *fMcEvt; //! 21 22 TH2D fBlindId; // 2D-histogram : pixel Id vs. Theta 23 TH2D fBlindN; // 2D-histogram : no.of blind pixels vs. Theta 15 24 16 25 public: 17 26 MHBlindPixels(const char *name=NULL, const char *title=NULL); 18 27 19 const TH 1D *GetHist() { return &fHist; }20 const TH 1D *GetHist() const { return &fHist; }28 const TH2D *GetBlindId() { return &fBlindId; } 29 const TH2D *GetBlindId() const { return &fBlindId; } 21 30 22 TH1 *GetHistByName(const TString name) { return &fHist; } 31 const TH2D *GetBlindN() { return &fBlindN; } 32 const TH2D *GetBlindN() const { return &fBlindN; } 33 34 TH2 *GetBlinIdByName(const TString name) { return &fBlindId; } 35 TH2 *GetBlinNByName(const TString name) { return &fBlindN; } 23 36 24 37 void Draw(Option_t* option = ""); 38 Bool_t SetupFill(const MParList *plist); 25 39 Bool_t Fill(const MParContainer *par, const Stat_t w=1); 26 40 27 ClassDef(MHBlindPixels, 1) // Histogram of blind pixel s41 ClassDef(MHBlindPixels, 1) // Histogram of blind pixel Id vs. Theta 28 42 }; 29 43 30 44 #endif 45 46 -
trunk/MagicSoft/Mars/mhist/MHMatrix.cc
r2104 r2128 788 788 // Calculate normalization factors 789 789 // 790 const int nbins = thsh.GetNbinsX(); 791 const double frombin = thsh.GetBinLowEdge(1); 792 const double tobin = thsh.GetBinLowEdge(nbins+1); 793 const double dbin = thsh.GetBinWidth(1); 790 //const int nbins = thsh.GetNbinsX(); 791 //const double frombin = thsh.GetBinLowEdge(1); 792 //const double tobin = thsh.GetBinLowEdge(nbins+1); 793 //const double dbin = thsh.GetBinWidth(1); 794 794 795 const Int_t nrows = fM.GetNrows(); 795 796 const Int_t ncols = fM.GetNcols(); … … 798 799 // set up the real histogram (distribution before) 799 800 // 800 TH1F hth("th", "Distribution before reduction", nbins, frombin, tobin); 801 //TH1F hth("th", "Distribution before reduction", nbins, frombin, tobin); 802 TH1F hth; 803 hth.SetNameTitle("th", "Distribution before reduction"); 804 SetBinning(&hth, &thsh); 801 805 hth.SetDirectory(NULL); 802 806 for (Int_t j=0; j<nrows; j++) 803 807 hth.Fill(fM(j, refcolumn)); 804 808 805 TH1F hthd("thd", "Correction factors", nbins, frombin, tobin); 809 //TH1F hthd("thd", "Correction factors", nbins, frombin, tobin); 810 TH1F hthd; 811 hthd.SetNameTitle("thd", "Correction factors"); 812 SetBinning(&hthd, &thsh); 806 813 hthd.SetDirectory(NULL); 807 814 hthd.Divide((TH1F*)&thsh, &hth, 1, 1); … … 840 847 TVector v(fM.GetNrows()); 841 848 v = TMatrixColumn(fM, refcolumn); 842 v += -frombin;843 v *= 1/dbin;849 //v += -frombin; 850 //v *= 1/dbin; 844 851 845 852 // … … 850 857 for (ir=0; ir<nrows; ir++) 851 858 { 852 const Int_t indref = (Int_t)v(ind[ir]);853 859 // const Int_t indref = (Int_t)v(ind[ir]); 860 const Int_t indref = hthd.FindBin(v(ind[ir])) - 1; 854 861 cumulweight[indref] += hthd.GetBinContent(indref+1); 855 862 if (cumulweight[indref]<=0.5) -
trunk/MagicSoft/Mars/mhist/MHSigmaTheta.cc
r2109 r2128 100 100 101 101 MBinning binspix("BinningPixel"); 102 binspix.SetEdges(57 7, -0.5, 577.5);102 binspix.SetEdges(578, -0.5, 577.5); 103 103 104 104 SetBinning(&fSigmaTheta, &binst, &binsb); … … 169 169 170 170 // Get binning for pixel number 171 const UInt_t npix = fPed->GetSize();171 const UInt_t npix1 = fPed->GetSize()+1; 172 172 173 173 MBinning binspix("BinningPixel"); 174 binspix.SetEdges(npix , -0.5, 0.5+npix);174 binspix.SetEdges(npix1, -0.5, npix1-0.5); 175 175 176 176 // Set binnings in histograms
Note:
See TracChangeset
for help on using the changeset viewer.