Changeset 7142
- Timestamp:
- 06/10/05 13:10:09 (19 years ago)
- Location:
- trunk/MagicSoft/Mars
- Files:
-
- 25 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/MagicSoft/Mars/Changelog
r7141 r7142 21 21 22 22 -*-*- END OF LINE -*-*- 23 2005/06/10 Daniela Dorner 24 25 * datacenter/macros/plotdb.C: 26 - set minimum and maximum also for ZA graph 27 28 * mdata/MDataChain.cc: 29 - fixed a possible crash to to NULL-acess in GetDataMember 30 31 * mhbase/MBinning.[h,cc]: 32 - added a new binning type "asin" which is used for the 33 ZA binning 34 35 * mhflux/MAlphaFitter.cc: 36 - allow polynom order 1 37 - improved result line in PaintResult 38 39 * mhflux/MHAlpha.cc: 40 - call PaintResult also in DrawAll 41 42 * mhflux/MHCollectionArea.cc: 43 - removede nonsense A_{eff} from plot 44 45 * mhflux/MHDisp.cc: 46 - fixed a possible crash if fSrcPos==NULL 47 48 * mhflux/MHAlpha.cc, mhflux/MHCollectionArea.cc, 49 mhflux/MHEffectiveOnTime.cc, mhflux/MHEnergyEst.cc, 50 mjobs/MJCut.cc: 51 - replaced SetEdgesCos by new SetEdgesASin (set the correct binning) 52 the old binning was not well aligned with the MC binning 53 54 * mhflux/MMcSpectrumWeight.[h,cc]: 55 - added the possibility to set ZA-weights 56 (Could be improved calculating correst sine-weights) 57 58 * mimage/MHVsSize.cc: 59 - fixed. Conc1 was incorrectly scaled 60 61 * mjobs/MDataSet.h: 62 - added getter for TLists 63 64 * mjobs/MJCut.cc: 65 - in non-wobble mode the hcalc2 had been wrrornously added 66 to the tasklist -> removed 67 68 * mjobs/MJOptimize.h: 69 - added a comment for EnableTestTrain 70 71 * mpointing/MSrcPosCam.[h,cc]: 72 - implemented Add member function 73 74 * mranforest/MRFEnergyEst.[h,cc]: 75 - fixed a problem with the removal of the last columns 76 - implemented debug-mode 77 - interpolate energy in logarithmic grid 78 - removed Test function completely 79 - added ReadEnv 80 81 * mranforest/MRanTree.[h,cc]: 82 - replaced some TMatrixFRow by TMatrixFRow_const 83 84 85 23 86 2005/06/08 Daniela Dorner 24 87 -
trunk/MagicSoft/Mars/NEWS
r7134 r7142 2 2 3 3 *** Version <cvs> 4 5 - general: Fixed the ZA binning. It didn't correctyl fit the 6 MC binning 7 8 - ganymed: the Conc1 plot was incorrectly scaled in MHVsSize 4 9 5 10 - mars: show muon parameters graphically … … 7 12 - mars: now the file to open can be given as commandline 8 13 argument 9 14 15 10 16 11 17 *** Version 0.9.3 (2005/06/03) -
trunk/MagicSoft/Mars/datacenter/macros/plotdb.C
r7129 r7142 97 97 g.SetNameTitle(name, Form("%s vs Time", name.Data())); 98 98 g.SetMarkerStyle(kFullDotMedium); 99 100 TGraph g2; 101 g2.SetNameTitle(name, Form("%s vs <Zd>", name.Data())); 102 g2.SetMarkerStyle(kFullDotMedium); 103 99 104 if (fmax>fmin) 100 105 { 101 106 g.SetMinimum(fmin); 102 107 g.SetMaximum(fmax); 108 g2.SetMinimum(fmin); 109 g2.SetMaximum(fmax); 103 110 } 104 105 TGraph g2;106 g2.SetNameTitle(name, Form("%s vs <Zd>", name.Data()));107 g2.SetMarkerStyle(kFullDotMedium);108 111 109 112 Int_t first = -1; -
trunk/MagicSoft/Mars/mdata/MDataChain.cc
r6831 r7142 832 832 TString MDataChain::GetDataMember() const 833 833 { 834 return fMember ->GetDataMember();834 return fMember ? fMember->GetDataMember() : ""; 835 835 } 836 836 837 837 void MDataChain::SetVariables(const TArrayD &arr) 838 838 { 839 return fMember->SetVariables(arr); 839 if (fMember) 840 fMember->SetVariables(arr); 840 841 } 841 842 -
trunk/MagicSoft/Mars/mhbase/MBinning.cc
r6954 r7142 261 261 // lo: lowest edge 262 262 // hi: highest edge 263 // type: "lin" <default>, "log", "cos" (without quotationmarks)263 // type: "lin" <default>, "log", "cos", "asin" (without quotationmarks) 264 264 // title: Whatever the title might be 265 265 // … … 296 296 str.Remove(0, pos); 297 297 str = str.Strip(TString::kBoth); 298 if (typ!=(TString)"lin" && typ!=(TString)"log" && typ!=(TString)"cos" )298 if (typ!=(TString)"lin" && typ!=(TString)"log" && typ!=(TString)"cos" && typ!=(TString)"asin") 299 299 { 300 300 *fLog << warn << GetDescriptor() << "::SetEdges: Type " << typ << " unknown... ignored." << endl; … … 384 384 return; 385 385 } 386 if (o.Contains("asin", TString::kIgnoreCase)) 387 { 388 SetEdgesASin(nbins, lo, up); 389 return; 390 } 386 391 if (o.Contains("cos", TString::kIgnoreCase)) 387 392 { … … 420 425 const Axis_t ud = up/kRad2Deg; 421 426 422 const Double_t binsize = (cos(ld)-cos(ud))/nbins; 427 const Double_t cld = ld<0 ? cos(ld)-1 : 1-cos(ld); 428 const Double_t cud = ud<0 ? cos(ud)-1 : 1-cos(ud); 429 430 SetEdgesASin(nbins, ld, ud); 431 /* 432 const Double_t binsize = (cld-cud)/nbins; 423 433 fEdges.Set(nbins+1); 424 434 for (int i=0; i<=nbins; i++) 425 fEdges[i] = acos(cos(ld)-binsize*i)*kRad2Deg; 435 { 436 const Double_t a = cld-binsize*i; 437 fEdges[i] = a<0 ? -acos(1+a)*kRad2Deg : acos(1-a)*kRad2Deg; 438 cout << a << " " << fEdges[i] << endl; 439 } 440 441 fType = kIsCosinic;*/ 442 } 443 444 // -------------------------------------------------------------------------- 445 // 446 // Specify the number of bins <nbins> (not the number of edges), the 447 // lowest [deg] <lo> and highest [deg] <up> Edge (of your histogram) 448 // 449 void MBinning::SetEdgesASin(const Int_t nbins, Axis_t lo, Axis_t up) 450 { 451 const Double_t binsize = nbins<=0 ? 0 : (up-lo)/nbins; 452 fEdges.Set(nbins+1); 453 for (int i=0; i<=nbins; i++) 454 { 455 const Double_t a = binsize*i + lo; 456 fEdges[i] = a<0 ? -acos(1+a)*kRad2Deg : acos(1-a)*kRad2Deg; 457 } 426 458 427 459 fType = kIsCosinic; … … 543 575 { 544 576 type = GetEnvValue(env, prefix, "Type", "lin"); 545 if (type!=(TString)"lin" && type!=(TString)"log" && type!=(TString)"cos" )577 if (type!=(TString)"lin" && type!=(TString)"log" && type!=(TString)"cos" && type!=(TString)"acos") 546 578 { 547 579 *fLog << warn << GetDescriptor() << "::ReadEnv - WARNING: Type is not lin, log nor cos... assuming lin." << endl; -
trunk/MagicSoft/Mars/mhbase/MBinning.h
r6958 r7142 66 66 void SetEdgesLog(const Int_t nbins, const Axis_t lo, Axis_t up); 67 67 void SetEdgesCos(const Int_t nbins, const Axis_t lo, Axis_t up); 68 void SetEdgesASin(const Int_t nbins, Axis_t lo, Axis_t up); 68 69 69 70 Int_t FindLoEdge(Double_t val) const -
trunk/MagicSoft/Mars/mhflux/MAlphaFitter.cc
r7093 r7142 117 117 118 118 fFunc->FixParameter(1, 0); 119 fFunc->FixParameter(4, 0); 119 if (fPolynomOrder!=1) 120 fFunc->FixParameter(4, 0); 120 121 fFunc->SetParLimits(2, 0, 90); 121 122 fFunc->SetParLimits(3, -1, 1); … … 159 160 fFunc->ReleaseParameter(2); 160 161 fFunc->FixParameter(3, fFunc->GetParameter(3)); 162 fFunc->FixParameter(4, fFunc->GetParameter(4)); 161 163 for (int i=5; i<fFunc->GetNpar(); i++) 162 164 fFunc->FixParameter(i, fFunc->GetParameter(i)); … … 297 299 const Int_t l1 = w<=0 ? 0 : (Int_t)TMath::Ceil(-TMath::Log10(w)); 298 300 const Int_t l2 = m<=0 ? 0 : (Int_t)TMath::Ceil(-TMath::Log10(m)); 299 const TString fmt = Form("\\sigma_{L i/Ma}=%%.1f \\omega=%%.%df\\circ E=%%d B=%%d (x<%%.%df) (\\chi_{b}^{2}/ndf=%%.1f \\chi_{s}^{2}/ndf=%%.1f c_{0}=%%.1f)",301 const TString fmt = Form("\\sigma_{L/M}=%%.1f \\omega=%%.%df\\circ E=%%d B=%%d x<%%.%df \\tilde\\chi_{b}=%%.1f \\tilde\\chi_{s}=%%.1f c=%%.1f f=%%.2f", 300 302 l1<1?1:l1+1, l2<1?1:l2+1); 301 303 302 304 TLatex text(x, y, Form(fmt.Data(), fSignificance, w, (int)fEventsExcess, 303 305 (int)fEventsBackground, m, fChiSqBg, fChiSqSignal, 304 fCoefficients[3] ));306 fCoefficients[3], fScaleFactor)); 305 307 306 308 text.SetBit(TLatex::kTextNDC); -
trunk/MagicSoft/Mars/mhflux/MHAlpha.cc
r7122 r7142 139 139 binsa.SetEdges(18, 0, 90); 140 140 binse.SetEdgesLog(15, 10, 100000); 141 binst.SetEdges Cos(50, 0, 60);141 binst.SetEdgesASin(51, -0.005, 0.505); 142 142 binse.Apply(fHEnergy); 143 143 binst.Apply(fHTheta); … … 818 818 819 819 if (hof ? fit.Fit(*hon, *hof, alpha) : fit.Fit(*hon)) 820 *fLog << dbg << "Bin " << i << ": sigma=" << fit.GetSignificance() << " omega=" << fit.GetGausSigma() << " events=" << fit.GetEventsExcess() << endl; 820 { 821 *fLog << dbg << "Bin " << i << ": sigma=" << fit.GetSignificance() << " omega=" << fit.GetGausSigma() << " events=" << fit.GetEventsExcess() << " scale=" << fit.GetScaleFactor() << endl; 822 fit.PaintResult(); 823 } 821 824 /* 822 825 if (fit.FitEnergy(fHist, fOffData, i, kTRUE)) -
trunk/MagicSoft/Mars/mhflux/MHCollectionArea.cc
r7094 r7142 95 95 MBinning binsa, binse, binst; 96 96 binse.SetEdgesLog(15, 10, 1000000); 97 binst.SetEdges Cos(50, 0, 60);97 binst.SetEdgesASin(51, -0.005, 0.505); 98 98 99 99 binse.Apply(fHEnergy); … … 289 289 if (TString(option)=="paint4") 290 290 { 291 const TString txt = Form("A_{eff}=%.0fm^{2} A_{abs}=%.0fm^{2} r=%.0fm", 292 GetCollectionAreaEff(), 291 //const TString txt = Form("A_{eff}=%.0fm^{2} A_{abs}=%.0fm^{2} r=%.0fm", 292 // GetCollectionAreaEff(), 293 // GetCollectionAreaAbs(), fMcAreaRadius); 294 const TString txt = Form("A_{abs}=%.0fm^{2} r=%.0fm", 293 295 GetCollectionAreaAbs(), fMcAreaRadius); 294 296 -
trunk/MagicSoft/Mars/mhflux/MHDisp.cc
r7122 r7142 203 203 204 204 // Now we can safly derotate both position... 205 TVector2 srcp(fSrcPos->GetXY()); 205 TVector2 srcp; 206 if (fSrcPos) 207 srcp = fSrcPos->GetXY(); 208 206 209 if (rho!=0) 207 210 { … … 211 214 } 212 215 213 if (fSrcPos) 214 { 215 pos1 -= srcp*fMm2Deg; 216 pos2 -= srcp*fMm2Deg; 217 } 216 pos1 -= srcp*fMm2Deg; 217 pos2 -= srcp*fMm2Deg; 218 218 219 219 fHist.Fill(pos1.X(), pos1.Y(), 0.0, w*gweight); -
trunk/MagicSoft/Mars/mhflux/MHEffectiveOnTime.cc
r7115 r7142 410 410 // setup binning 411 411 MBinning btheta("BinningTheta"); 412 btheta.SetEdges Cos(100, 0, 60);412 btheta.SetEdgesASin(51, -0.005, 0.505); 413 413 414 414 MBinning btime("BinningDeltaT"); -
trunk/MagicSoft/Mars/mhflux/MHEnergyEst.cc
r6983 r7142 96 96 MBinning binsi, binse, binst, binsr; 97 97 binse.SetEdgesLog(15, 10, 1000000); 98 binst.SetEdges Cos(50, 0, 60);98 binst.SetEdgesASin(51, -0.005, 0.505); 99 99 binsi.SetEdges(10, 0, 400); 100 100 binsr.SetEdges(50, -1.3, 1.3); -
trunk/MagicSoft/Mars/mhflux/MMcSpectrumWeight.cc
r7130 r7142 72 72 73 73 #include <TF1.h> 74 #include <TH1.h> 74 75 75 76 #include "MLog.h" … … 79 80 #include "MParameters.h" 80 81 82 #include "MPointingPos.h" 83 81 84 #include "MMcEvt.hxx" 82 85 #include "MMcCorsikaRunHeader.h" … … 106 109 fAllowChange = kFALSE; 107 110 108 fFunc = NULL; 109 fMcEvt = NULL; 110 fWeight = NULL; 111 fFunc = NULL; 112 fMcEvt = NULL; 113 fWeight = NULL; 114 fZdWeights = NULL; 115 fPointing = NULL; 111 116 } 112 117 … … 150 155 if (!fWeight) 151 156 return kFALSE; 157 158 if (!fZdWeights) 159 return kTRUE; 160 161 fPointing = (MPointingPos*)pList->FindObject("MPointingPos"); 162 if (!fPointing) 163 { 164 *fLog << err << "MPointingPos not found... abort." << endl; 165 return kFALSE; 166 } 152 167 153 168 return kTRUE; … … 362 377 const Double_t e = fMcEvt->GetEnergy(); 363 378 364 fWeight->SetVal(fFunc->Eval(e)); 379 Double_t w = 1; 380 381 if (fZdWeights) 382 { 383 const Int_t i = fZdWeights->GetXaxis()->FindFixBin(fPointing->GetZd()); 384 w = fZdWeights->GetBinContent(i); 385 cout << i << " " << w << " " << fPointing->GetZd() << endl; 386 } 387 388 fWeight->SetVal(fFunc->Eval(e)*w); 365 389 366 390 return kTRUE; -
trunk/MagicSoft/Mars/mhflux/MMcSpectrumWeight.h
r7094 r7142 7 7 8 8 class TF1; 9 class TH1; 9 10 class MParList; 10 11 class MMcEvt; 11 12 class MParameterD; 13 class MPointingPos; 12 14 class MMcCorsikaRunHeader; 13 15 … … 17 19 const MMcEvt *fMcEvt; // Pointer to the container with the MC energy 18 20 MParameterD *fWeight; // Pointer to the output MWeight container 21 MPointingPos *fPointing; 19 22 20 23 TString fNameWeight; // Name of the MWeight container … … 22 25 23 26 TF1 *fFunc; // Function calculating the weights 27 TH1 *fZdWeights; // Set additional ZA weights 24 28 25 29 Double_t fOldSlope; // Slope of energy spectrum generated with Corsika … … 59 63 void SetEnergyRange(Double_t min=-2, Double_t max=-1) { fEnergyMin=min; fEnergyMax=max; } 60 64 void SetOldSlope(Double_t s=-2.6) { fOldSlope=s; } 65 void SetZdWeights(TH1 *h=0) { fZdWeights = h; } 61 66 Bool_t Set(const MMcCorsikaRunHeader &h); 62 67 -
trunk/MagicSoft/Mars/mimage/MHVsSize.cc
r6961 r7142 99 99 binsl.SetEdges( 100, 0, 296.7/2); 100 100 binsd.SetEdges( 100, 0, 600); 101 binsc.SetEdgesLog(100, 1e-5, 5e-3);101 binsc.SetEdgesLog(100, 3e-3, 1); 102 102 binsa.SetEdges( 100, 0, 445*45); 103 103 binsm.SetEdges( 100, -445, 445); … … 269 269 fWidth.Fill( fHillas->GetSize(), scale*fHillas->GetWidth(), w); 270 270 fDist.Fill( fHillas->GetSize(), scale*src->GetDist(), w); 271 fConc1.Fill( fHillas->GetSize(), scale*fNewImagePar->GetConc1(),w);271 fConc1.Fill( fHillas->GetSize(), fNewImagePar->GetConc1(), w); 272 272 fArea.Fill( fHillas->GetSize(), scale*scale*fHillas->GetArea(), w); 273 273 fM3Long.Fill(fHillas->GetSize(), scale*fHillasExt->GetM3Long()*TMath::Sign(1.0f, src->GetCosDeltaAlpha()), w); -
trunk/MagicSoft/Mars/mjobs/MDataSet.h
r6958 r7142 60 60 static Int_t AddFilesToChain(MDirIter &files, TChain &chain); 61 61 62 const TList &GetSequencesOn() const { return fSequencesOn; } 63 const TList &GetSequencesOff() const { return fSequencesOff; } 64 62 65 Bool_t AddFiles(MRead &read) const; 63 66 Bool_t AddFilesOn(MRead &read) const; -
trunk/MagicSoft/Mars/mjobs/MJCut.cc
r7115 r7142 448 448 449 449 // Initialize default binnings 450 MBinning bins1(18, 0, 90,"BinningAlpha", "lin");451 MBinning bins2(15, 10, 1e6 ,"BinningEnergyEst", "log");452 MBinning bins3(5 0, 0, 60, "BinningTheta", "cos");450 MBinning bins1(18, 0, 90, "BinningAlpha", "lin"); 451 MBinning bins2(15, 10, 1e6 , "BinningEnergyEst", "log"); 452 MBinning bins3(51, -0.005, 0.505, "BinningTheta", "asin"); 453 453 MBinning bins4("BinningFalseSource"); 454 454 MBinning bins5("BinningWidth"); … … 559 559 tlist2.AddToList(&scalc); 560 560 tlist2.AddToList(&hcalc); 561 //if (fIsWobble)561 if (fIsWobble) 562 562 tlist2.AddToList(&hcalc2); 563 563 //tlist2.AddToList(&taskenv1); -
trunk/MagicSoft/Mars/mjobs/MJOptimize.h
r7121 r7142 111 111 void SetNumMaxCalls(UInt_t num=0) { fNumMaxCalls=num; } 112 112 void SetTolerance(Float_t tol=0) { fTolerance=tol; } 113 void EnableTestTrain(Int_t b= 2) { fTestTrain=b; }113 void EnableTestTrain(Int_t b=1) { fTestTrain=b; } // Use 1 and -1 114 114 115 115 // Parameter access -
trunk/MagicSoft/Mars/mpointing/MSrcPosCam.cc
r7109 r7142 62 62 // Copy constructor, set default name and title 63 63 // 64 MSrcPosCam::MSrcPosCam(const MSrcPosCam &p) : fX(p.fX), fY(p ,fY)64 MSrcPosCam::MSrcPosCam(const MSrcPosCam &p) : fX(p.fX), fY(p.fY) 65 65 { 66 66 fName = gsDefName.Data(); … … 69 69 70 70 // ----------------------------------------------------------------------- 71 // 72 // Print contents 71 73 // 72 74 void MSrcPosCam::Print(Option_t *) const … … 78 80 } 79 81 82 // ----------------------------------------------------------------------- 83 // 84 // Set fX to v.X() and fY to v.Y() 85 // 80 86 void MSrcPosCam::SetXY(const TVector2 &v) 81 87 { … … 84 90 } 85 91 92 // ----------------------------------------------------------------------- 93 // 94 // Add v.X() to fX and v.Y() to fY 95 // 96 void MSrcPosCam::Add(const TVector2 &v) 97 { 98 fX+=v.X(); 99 fY+=v.Y(); 100 } 101 102 // ----------------------------------------------------------------------- 103 // 104 // Get TVector2(fX, fY) 105 // 86 106 TVector2 MSrcPosCam::GetXY() const 87 107 { -
trunk/MagicSoft/Mars/mpointing/MSrcPosCam.h
r7109 r7142 25 25 void SetXY(const TVector2 &v); 26 26 27 void Add(const TVector2 &v); 28 27 29 Float_t GetX() const { return fX; } 28 30 Float_t GetY() const { return fY; } 29 31 TVector2 GetXY() const; 32 30 33 31 34 void Print(Option_t *opt=NULL) const; -
trunk/MagicSoft/Mars/mpointing/Makefile
r6048 r7142 28 28 MSrcPosCam.cc \ 29 29 MSrcPosCalc.cc \ 30 MSrcPosCorrect.cc \ 30 31 MSrcPosFromModel.cc 31 32 -
trunk/MagicSoft/Mars/mranforest/MRFEnergyEst.cc
r7130 r7142 69 69 // 70 70 MRFEnergyEst::MRFEnergyEst(const char *name, const char *title) 71 : fNumTrees(-1), fNumTry(-1), fNdSize(-1), fD ata(0), fEnergyEst(0),72 f TestMatrix(0)71 : fNumTrees(-1), fNumTry(-1), fNdSize(-1), fDebug(kFALSE), 72 fData(0), fEnergyEst(0), fTestMatrix(0) 73 73 { 74 74 fName = name ? name : gsDefName.Data(); … … 91 91 } 92 92 93 const Int_t ncols = matrixtrain.GetM().GetNcols(); 94 const Int_t nrows = matrixtrain.GetM().GetNrows(); 93 const TMatrix &m = matrixtrain.GetM(); 94 95 const Int_t ncols = m.GetNcols(); 96 const Int_t nrows = m.GetNrows(); 95 97 if (ncols<=0 || nrows <=0) 96 98 { … … 114 116 } 115 117 118 const Int_t nobs = 3; // Number of obsolete columns 119 116 120 MDataArray usedrules; 117 for(Int_t i=0; i<ncols- 3; i++) // -3 is important!!!121 for(Int_t i=0; i<ncols-nobs; i++) // -3 is important!!! 118 122 usedrules.AddEntry((*matrixtrain.GetColumns())[i].GetRule()); 119 120 const TMatrix &m = matrixtrain.GetM();121 123 122 124 // training of RF for each energy bin … … 140 142 } 141 143 142 const Bool_t valid = irow1*irow0>0;143 144 if ( !valid)144 const Bool_t invalid = irow1==0 || irow0==0; 145 146 if (invalid) 145 147 *fLog << warn << "WARNING - Skipping"; 146 148 else 147 149 *fLog << inf << "Training RF for"; 148 150 149 *fLog << " energy bin " << ie << " (" << grid[ie] << ", " << grid[ie+1] << ") "<< endl;150 151 if ( !valid)151 *fLog << " energy bin " << ie << " (" << grid[ie] << ", " << grid[ie+1] << ") " << irow0 << " " << irow1 << endl; 152 153 if (invalid) 152 154 continue; 153 155 154 gLog.SetNullOutput(kTRUE); 156 if (fDebug) 157 gLog.SetNullOutput(kTRUE); 155 158 156 159 // last column must be removed (true energy col.) 157 mat1.ResizeTo(irow1, ncols- 1);158 mat0.ResizeTo(irow0, ncols- 1);160 mat1.ResizeTo(irow1, ncols-nobs); 161 mat0.ResizeTo(irow0, ncols-nobs); 159 162 160 163 // create MHMatrix as input for RF … … 183 186 evtloop.SetParList(&plist); 184 187 185 gLog.SetNullOutput(kFALSE); 188 if (fDebug) 189 gLog.SetNullOutput(kFALSE); 186 190 187 191 if (!evtloop.Eventloop()) 188 192 return kFALSE; 189 193 194 const Double_t E = (log10(grid[ie])+log10(grid[ie+1]))/2; 195 190 196 // save whole forest 191 197 MRanForest *forest=(MRanForest*)plist.FindObject("MRanForest"); 192 const TString title = Form("%f", TMath::Sqrt(grid[ie]*grid[ie+1])); 193 //const TString title = Form("%f", (grid[ie]+grid[ie+1])/2); 198 const TString title = Form("%.10f", E); 194 199 forest->SetTitle(title); 195 200 forest->Write(title); … … 203 208 return kTRUE; 204 209 } 205 /* 206 Int_t MRFEnergyEst::Test(const MHMatrix &matrixtest) 207 { 208 gLog.Separator("MRFEnergyEst - Test"); 209 210 const Int_t ncols = matrixtest.GetM().GetNcols(); 211 const Int_t nrows = matrixtest.GetM().GetNrows(); 212 213 if (ncols<=0 || nrows <=0) 214 { 215 *fLog << err << dbginf << "No. of columns or no. of rows of matrixtrain equal 0 ... aborting." << endl; 216 return kFALSE; 217 } 218 219 if (!ReadForests()) 220 { 221 *fLog << err << dbginf << "Reading RFs failed... aborting." << endl; 222 return kFALSE; 223 } 224 225 const Int_t nbins=fEForests.GetSize(); 226 227 Double_t elow = FLT_MAX; 228 Double_t eup = -FLT_MAX; 229 230 for(Int_t j=0;j<nbins;j++) 231 { 232 elow = TMath::Min(atof(fEForests[j]->GetTitle()), elow); 233 eup = TMath::Max(atof(fEForests[j]->GetTitle()), eup); 234 } 235 236 TH1F hres("hres", "", 1000, -10, 10); 237 TH2F henergy("henergy", "",100, elow, eup,100, elow, eup); 238 239 const TMatrix &m=matrixtest.GetM(); 240 for(Int_t i=0;i<nrows;i++) 241 { 242 Double_t etrue = m(i,ncols-1); 243 Double_t eest = 0; 244 Double_t hsum = 0; 245 246 for(Int_t j=0;j<nbins;j++) 247 { 248 const TVector v = TMatrixFRow_const(m,i); 249 250 const Double_t h = ((MRanForest*)fEForests[j])->CalcHadroness(v); 251 const Double_t e = atof(fEForests[j]->GetTitle()); 252 253 hsum += h; 254 eest += h*e; 255 } 256 eest /= hsum; 257 eest = pow(10., eest); 258 259 //if (etrue>80.) 260 // hres.Fill((eest-etrue)/etrue); 261 262 henergy.Fill(log10(etrue),log10(eest)); 263 } 264 265 if(gStyle) 266 gStyle->SetOptFit(1); 267 268 // show results 269 TCanvas *c=MH::MakeDefCanvas("c","",300,900); 270 271 c->Divide(1,3); 272 c->cd(1); 273 henergy.SetTitle("Estimated vs true energy"); 274 henergy.GetXaxis()->SetTitle("log10(E_{true}[GeV])"); 275 henergy.GetYaxis()->SetTitle("log10(E_{est}[GeV])"); 276 henergy.DrawCopy(); 277 278 c->cd(2); 279 TH1F *hptr=(TH1F*)henergy.ProfileX("_px",1,100,"S"); 280 hptr->SetTitle("Estimated vs true energy - profile"); 281 hptr->GetXaxis()->SetTitle("log10(E_{true}[GeV])"); 282 hptr->GetYaxis()->SetTitle("log10(E_{est}[GeV])"); 283 hptr->DrawCopy(); 284 285 c->cd(3); 286 hres.Fit("gaus"); 287 hres.SetTitle("Energy resolution for E_{true}>80Gev"); 288 hres.GetXaxis()->SetTitle("(E_{estimated}-E_{true})/E_{true})"); 289 hres.GetYaxis()->SetTitle("counts"); 290 hres.DrawCopy(); 291 292 c->GetPad(1)->SetGrid(); 293 c->GetPad(2)->SetGrid(); 294 c->GetPad(3)->SetGrid(); 295 296 return kTRUE; 297 } 298 */ 299 Int_t MRFEnergyEst::ReadForests(MParList *plist) 210 211 Int_t MRFEnergyEst::ReadForests(MParList &plist) 300 212 { 301 213 TFile fileRF(fFileName,"read"); … … 321 233 322 234 fEForests.Add(forest); 323 324 } 325 326 if (plist) 327 { 328 fData = (MDataArray*)plist->FindCreateObj("MDataArray"); 329 fData->Read("rules"); 330 } 331 332 fileRF.Close(); 235 } 236 237 if (fData->Read("rules")<=0) 238 { 239 *fLog << err << "ERROR - Reading 'rules' from file " << fFileName << endl; 240 return kFALSE; 241 } 333 242 334 243 return kTRUE; … … 341 250 return kFALSE; 342 251 343 if (!ReadForests(plist)) 252 fData = (MDataArray*)plist->FindCreateObj("MDataArray"); 253 if (!fData) 254 return kFALSE; 255 256 if (!ReadForests(*plist)) 344 257 { 345 258 *fLog << err << "Reading RFs failed... aborting." << endl; 346 259 return kFALSE; 347 260 } 261 262 *fLog << inf << "RF read from " << fFileName << endl; 348 263 349 264 if (fTestMatrix) 350 265 return kTRUE; 351 266 352 if (!fData) 353 { 354 *fLog << err << "MDataArray not found... aborting." << endl; 355 return kFALSE; 356 } 267 fData->Print(); 357 268 358 269 if (!fData->PreProcess(plist)) … … 387 298 388 299 hsum += h; 389 eest += h*e;390 } 391 392 fEnergyEst->SetVal( eest/hsum);300 eest += e*h; 301 } 302 303 fEnergyEst->SetVal(pow(10, eest/hsum)); 393 304 fEnergyEst->SetReadyToSave(); 394 305 395 306 return kTRUE; 396 307 } 308 309 // -------------------------------------------------------------------------- 310 // 311 // 312 Int_t MRFEnergyEst::ReadEnv(const TEnv &env, TString prefix, Bool_t print) 313 { 314 Bool_t rc = kFALSE; 315 if (IsEnvDefined(env, prefix, "FileName", print)) 316 { 317 rc = kTRUE; 318 SetFileName(GetEnvValue(env, prefix, "FileName", fFileName)); 319 } 320 if (IsEnvDefined(env, prefix, "Debug", print)) 321 { 322 rc = kTRUE; 323 SetDebug(GetEnvValue(env, prefix, "Debug", fDebug)); 324 } 325 return rc; 326 } -
trunk/MagicSoft/Mars/mranforest/MRFEnergyEst.h
r7134 r7142 23 23 Int_t fNdSize; // Training parameters 24 24 25 Bool_t fDebug; // Debugging of eventloop while training on/off 26 25 27 TString fFileName; 26 28 TObjArray fEForests; … … 34 36 Int_t Process(); 35 37 36 Int_t ReadForests(MParList *plist=NULL); 38 Int_t ReadForests(MParList &plist); 39 40 Int_t ReadEnv(const TEnv &env, TString prefix, Bool_t print); 37 41 38 42 public: … … 41 45 void SetFileName(TString str) { fFileName = str; } 42 46 43 void SetNumTrees(Int_t n=-1) { fNumTrees = n; }44 void SetNdSize(Int_t n=-1) { fNdSize = n; }45 void SetNumTry(Int_t n=-1) { fNumTry = n; }47 void SetNumTrees(Int_t n=-1) { fNumTrees = n; } 48 void SetNdSize(Int_t n=-1) { fNdSize = n; } 49 void SetNumTry(Int_t n=-1) { fNumTry = n; } 46 50 47 51 void SetTestMatrix(MHMatrix *m=0) { fTestMatrix=m; } 48 52 void InitMapping(MHMatrix *m=0) { fTestMatrix=m; } 53 54 void SetDebug(Bool_t b=kTRUE) { fDebug = b; } 49 55 50 56 Int_t Train(const MHMatrix &n, const TArrayD &grid); -
trunk/MagicSoft/Mars/mranforest/MRanTree.cc
r4647 r7142 447 447 // are coded into fBestVar: 448 448 // status of node kt = TMath::Sign(1,fBestVar[kt]) 449 // class of node kt = fBestVar[kt]+2 (class defined by larger450 // node population, actually not used)449 // class of node kt = fBestVar[kt]+2 450 // (class defined by larger node population, actually not used) 451 451 // hadronness assigned to node kt = fBestSplit[kt] 452 452 … … 463 463 } 464 464 465 Double_t MRanTree::TreeHad(const TMatrix Row&event)465 Double_t MRanTree::TreeHad(const TMatrixFRow_const &event) 466 466 { 467 467 Int_t kt=0; … … 504 504 Bool_t MRanTree::AsciiWrite(ostream &out) const 505 505 { 506 TString str; 506 out.width(5); 507 out << fNumNodes << endl; 508 507 509 Int_t k; 508 509 out.width(5);out<<fNumNodes<<endl; 510 511 for (k=0;k<fNumNodes;k++) 512 { 513 str=Form("%f",GetBestSplit(k)); 510 for (k=0; k<fNumNodes; k++) 511 { 512 TString str=Form("%f", GetBestSplit(k)); 514 513 515 514 out.width(5); out << k; … … 521 520 out.width(5); out << GetNodeClass(k); 522 521 } 523 out <<endl;524 525 return k ==fNumNodes;526 } 522 out << endl; 523 524 return kTRUE; 525 } -
trunk/MagicSoft/Mars/mranforest/MRanTree.h
r2307 r7142 16 16 class TMatrix; 17 17 class TMatrixRow; 18 class TMatrixFRow_const; 18 19 class TVector; 19 20 class TRandom; … … 84 85 85 86 Double_t TreeHad(const TVector &event); 86 Double_t TreeHad(const TMatrix Row&event);87 Double_t TreeHad(const TMatrixFRow_const &event); 87 88 Double_t TreeHad(const TMatrix &m, Int_t ievt); 88 89 Double_t TreeHad();
Note:
See TracChangeset
for help on using the changeset viewer.