/* ======================================================================== *\ ! ! * ! * This file is part of MARS, the MAGIC Analysis and Reconstruction ! * Software. It is distributed to you in the hope that it can be a useful ! * and timesaving tool in analysing Data of imaging Cerenkov telescopes. ! * It is distributed WITHOUT ANY WARRANTY. ! * ! * Permission to use, copy, modify and distribute this software and its ! * documentation for any purpose is hereby granted without fee, ! * provided that the above copyright notice appear in all copies and ! * that both that copyright notice and this permission notice appear ! * in supporting documentation. It is provided "as is" without express ! * or implied warranty. ! * ! ! ! Author(s): Wolfgang Wittek 10/2003 ! ! Copyright: MAGIC Software Development, 2000-2003 ! ! \* ======================================================================== */ ///////////////////////////////////////////////////////////////////////////// // // M2dimFunction // // Storage Container for the parameters of the 2-dim function describing // the shower image // // ///////////////////////////////////////////////////////////////////////////// #include "M2dimFunction.h" #include > #include "TMath.h" #include "TVectorD.h" #include "TMatrixD.h" #include "MLog.h" #include "MLogManip.h" #include "MHillas.h" #include "MGeomCam.h" #include "MGeomPix.h" #include "MCerPhotEvt.h" #include "MCerPhotPix.h" ClassImp(M2dimFunction); using namespace std; // -------------------------------------------------------------------------- // // TwodimFunction // // this function calculates for a given set of parameters // // - the log likelihood function L to be minimized // - beta_k = -1/2 * dL/da_k (a kind of gradient of L) // - alfa_kl = 1/2 * dL/(da_k da_l) (a kind of second derivative of L) // // (see Numerical recipes (2nd ed.), W.H.Press et al., p. 687) // // Note : this is not a member function of M2dimFunction; // it will be called by the minimization class MMarquardt; // the address of this function is passed to MMarquardt // in M2dimFunction::Fit() by the call MMarquardt::Loop() // Bool_t TwodimFunction(TVectord &a, TMatrixD &alfa, TVectord &beta, Double_t &L) { Int_t npar = a.GetNrows(); Int_t npixels =; TMatrixD dmuda (npar, npixels); TVector dLdmu (npixels); TVector d2Ldmu2(npixels); //------------------------------------------ // these are the parameters for which alfa, beta and L are calculated Double_t xbar = a(0); Double_t ybar = a(1); Double_t delta = a(2); Double_t amp = a(3); Double_t leng = a(4); Double_t wid = a(5); Double_t asy = a(6); for (Int_t m=0; mGetMeanX(); fVinit(1) = fhillas->GetMeanY(); fVinit(2) = fhillas->GetDelta(); } else { fVinit(0) = ; fVinit(1) = ; fVinit(2) = ; } fVinit(3) = fVinit(4) = fVinit(5) = fVinit(6) = return; } // -------------------------------------------------------------------------- // // Fit of the 2-dim function to the shower image // void M2dimFunction::Fit() { fMarquardt.Loop(TwodimFunction, fVinit); SetReadyToSave(); } // -------------------------------------------------------------------------- // void M2dimFunction::Print(Option_t *) const { *fLog << all; *fLog << "Parameters of 2-dim function (" << GetName() << ")" << endl; *fLog << " - fXbar = " << fXbar << endl; *fLog << " - fYbar = " << fYbar << endl; *fLog << " - fAmp = " << fAmp << endl; *fLog << " - fMajor = " << fMajor << endl; *fLog << " - fMinor = " << fMinor << endl; *fLog << " - fAsym = " << fAsym << endl; } //============================================================================