Beispiel #1
0
void KVIDentifier::CloneScaleStore(Int_t newzt, Int_t newar, Double_t dy, Double_t sx, Double_t sy)
{
   // Create a new line from the selected one
   // with a new Z and A (optional)
   // this new line is scale from the selected one with a vertical sy
   // and horizontal sx (optional) factor
   // you need to undraw and draw the grid to see its implementation

   TClass* cl = new TClass(this->IsA()->GetName());
   KVIDentifier* idbis = (KVIDentifier*)cl->New();
   Double_t xx, yy;
   for (Int_t nn = 0; nn < this->GetN(); nn += 1) {
      this->GetPoint(nn, xx, yy);
      idbis->SetPoint(nn, xx, yy + dy);
   }
   idbis->SetOnlyZId(OnlyZId());
   idbis->SetZ(newzt);
   idbis->SetMassFormula(GetMassFormula());
   idbis->SetEditable(IsEditable());
   if (newar != -1) {
      idbis->SetA(newar);
   }
   if ((sx > 0.) && (sy > 0.)) idbis->Scale(sx, sy);
   this->GetParent()->AddIdentifier(idbis);

   this->GetParent()->UnDraw();
   this->GetParent()->Draw();


   delete cl;
}
Beispiel #2
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;
}
Beispiel #3
0
KVIDentifier::KVIDentifier(const KVIDentifier& gr)
   : TCutG(), fIon(1, 1)
{
   // copy constructor
   // we do not copy the fParent pointer to parent grid,
   // it is left NULL.
   init();
   gr.Copy(*this);
}
void KVDP2toCsIGridConvertor::Convert(const Char_t* id_and_imf_file, const Char_t* gamma_file)
{
   //Read ID and Gamma-line files for CsI R-L identifications.
   //Initialise grids in KVIDCsI telescopes

   if (fGrids) fGrids->Clear();
   else fGrids = new TList;
   ReadFile(id_and_imf_file);
   // set name of all IMF lines
   TIter nextGrid(fGrids);
   KVIDGrid* grid;
   KVIDentifier* line;
   while ((grid = (KVIDGrid*)nextGrid())) {
      TIter nextOK(grid->GetCuts());
      while ((line = (KVIDentifier*) nextOK())) {
         line->SetName("IMF_line");
      }
   }
   ReadGammaFile(gamma_file);
   if (gIDGridManager) gIDGridManager->GetGrids()->AddAll(fGrids);
   else Error(KV__ERROR(Convert), "gIDGridManager=0x0: create an ID grid manager first!");
}
Beispiel #5
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();
}