예제 #1
0
//______________________________________________________________________________
Int_t KVIDentifier::ContinueDrawing()
{
   // Continue to draw an existing the line
   if (!GetEditable()) return -2;

   KVIDentifier* gr = (KVIDentifier*)this->IsA()->New();
   gr->WaitForPrimitive();
   ChechHierarchy(gr);

   Int_t np = gr->GetN();

   Double_t last, first, yy;
   gr->GetPoint(np - 1, last, yy);
   gr->GetPoint(0, first, yy);

   Double_t xmax = fX[fNpoints - 1];
   Double_t xmin = fX[0];

   Info("ContinueDrawing", "Existing Line %lf %lf, Added line %lf %lf", xmin, xmax, last, first);

   if (first > xmax) {
      //A rajouter apres (a droite) de la ligne existante
      Double_t xx;
      for (Int_t ii = 0; ii < np; ii += 1) {
         gr->GetPoint(ii, xx, yy);
         this->SetPoint(fNpoints, xx, yy);
      }
   } else if (last < xmin) {
      //A rajouter avant (a gauche) la ligne existante
      Double_t xx;
      for (Int_t ii = 0; ii < fNpoints; ii += 1) {
         this->GetPoint(ii, xx, yy);
         gr->SetPoint(gr->GetN(), xx, yy);
      }

      for (Int_t ii = 0; ii < gr->GetN(); ii += 1) {
         gr->GetPoint(ii, xx, yy);
         this->SetPoint(ii, xx, yy);
      }
   } else {
      Info("ContinueDrawing", "Faire une extension a droite ou a gauche\nsans recouvrement avec la ligne existante");
   }

   delete gr;
   gPad->Modified();

   return np;
}
예제 #2
0
void KVTGIDFitter::Fit(KVIDGraph* theGrid)
{
   // Fit the grid using the functional chosen with SetType and SetLight.
   // Status of fit after this call can be retrieved with GetFitStatus().

   // must inherit from KVIDZAGrid!
   if (!theGrid->InheritsFrom(KVIDZAGrid::Class())) {
      Error("Fit(KVIDGraph*)",
            "Can only fit graphs inheriting from KVIDZAGrid");
      fGrid = 0;
      return;
   }
   fGrid = theGrid;
   fZorA = (Int_t)theGrid->OnlyZId();
   // prepare new parameter array and status array
   if (fPar) delete [] fPar;
   Int_t npar = KVTGID::GetNumberOfLTGParameters(fType, fLight);
   fPar = new Float_t[npar];
   if (istate) delete [] istate;
   istate = new Int_t[npar];

   //initialise grid - this should sort lines in order of Z & A
   theGrid->Initialize();

   //limit points according to abscissa ?
   Bool_t with_xlimits = (fXmax > fXmin);

   // calculate total number of points to fit
   Int_t npts = 0;
   TIter next_id(theGrid->GetIdentifiers());
   KVIDentifier* id;
   while ((id = (KVIDentifier*)next_id())) {
      if (!with_xlimits) {
         npts += id->GetN(); // count all points
      }
      else {
         Double_t x, y;
         for (int i = 0; i < id->GetN(); i++) {
            id->GetPoint(i, x, y);
            if (x >= fXmin && x <= fXmax) ++npts; // only points between [fXmin,fXmax]
         }
      }
   }
   cout << "Points to fit = " << npts << endl;
   if (npts < 2) {
      Error("Fit(KVIDGraph*)",
            "Too few points for fit");
      irc = -2;
      return;
   }

   // prepare and fill arrays with Z, A, X & Y
   if (zd) delete [] zd;
   if (ad) delete [] ad;
   if (xd) delete [] xd;
   if (yd) delete [] yd;
   zd = new Float_t[npts];
   ad = new Float_t[npts];
   xd = new Float_t[npts];
   yd = new Float_t[npts];
   next_id.Reset();
   npts = 0;
   Double_t x, y;
   while ((id = (KVIDentifier*)next_id())) {
      for (int i = 0; i < id->GetN(); i++) {
         id->GetPoint(i, x, y);
         if ((!with_xlimits) || (x >= fXmin && x <= fXmax)) {
            xd[npts] = (Float_t)x;
            yd[npts] = (Float_t)y;
            zd[npts] = id->GetZ();
            ad[npts] = id->GetA();
            ++npts;
         }
      }
   }

   /*** FIT FONCTIONNELLE ***/
   irc = globede_c(npts, zd, ad, xd, yd, fType, fLight, fPar, istate);

   //generate TGID corresponding to fit
   MakeTGID();
}