Exemplo n.º 1
0
void KVTGIDFitter::FitPanel(Int_t functional_type, Bool_t with_csi_light_energy,
                            Int_t first_Z, Int_t last_Z, Double_t xmin, Double_t xmax)
{
   // GUI method used to fit grid previously set with SetGrid(KVIDGraph*).
   //  functional_type = 0 (standard) or 1 (extended functional)
   //  with_csi_light_energy = kTRUE (with) or kFALSE (without CsI light-energy relation for 'X')
   //  first_Z, last_Z: set minimum & maximum Z for which fit is valid in KVTGID object
   //                   resulting from fit. (default: -1, take first and last Z of grid)
   //  xmin, xmax: only fit points with abscissa between limits [xmin,xmax]
   //                     (default: use all points regardless of abscissa)

   if (!fGrid) {
      Error("FitPanel", "Set grid to fit with SetGrid(KVIDGraph*)");
      return;
   }
   SetType(functional_type);
   SetLight((Int_t)with_csi_light_energy);
   fXmin = xmin;
   fXmax = xmax;
   Fit(fGrid);
   if (irc > 1 || irc < 0) {
      Warning("FitPanel", "Fit failed. Status of fit = %d", irc);
      return;
   }
   if (!fTGID) {
      Error("FitPanel", "Fit failed : %s", GetFitStatusString());
      return;
   }

   if (first_Z != -1) fTGID->SetIDmin(first_Z);
   if (last_Z != -1) fTGID->SetIDmax(last_Z);

   if (fGrid->GetXmin() == fGrid->GetXmax()) fGrid->FindAxisLimits();
   // generate grid representing fit
   KVTGIDGrid* fitgr = new KVTGIDGrid(fTGID, (KVIDZAGrid*)fGrid);
   // make fitted grid 'onlyzid' if parent grid was
   fitgr->SetOnlyZId(fGrid->OnlyZId());
   if (fGrid->OnlyZId()) fitgr->SetMassFormula(fGrid->GetMassFormula());
   fitgr->Generate(fGrid->GetXmax(), fGrid->GetXmin());
   gIDGridManager->Modified();

   if (fPad) {
      // draw fitted grid in same pad as original
      fPad->cd();
      fitgr->Draw();
      fPad->Modified();
      fPad->Update();
   }
}
Exemplo n.º 2
0
void KVRTGIDManager::BuildGridForAllTGID(const Char_t *idtype, Double_t xmin, Double_t xmax, Int_t ID_min, Int_t ID_max, Int_t npoints, Bool_t logscale){
	// Build a grid (KVTGIDGrid) for all the identification functions
	// of the global list. The new grids are automatically loaded in
	// gIDGridManager and are visible in the Grid Manager GUI.
	// If a function is already associated to a grid then a new grid
	// is not built. No grid is built for copies of KVTGID's made in
	// the method ReadAsciiFile(...).
	//
	// Inputs:  idtype - type of the identification for which the 
	//                   grids will be built (CI-SI, SI-CSI, CI-CSI,
	//                   SI75-SILI, ...). By default, all grids are
	//                   built
	//          xmin
	//          xmax
	//          ID_min
	//          ID_max
	//          npoints
	//          logscale - see KVTGIDGrid::Generate(...)

	if( !fIDGlobalList ) return;

	// First make a sublist of TGID found in object inheriting
	// from KVTGIDGrid in gIDGridManager
	TList  tgid_list;
	GetTGIDfromIDGridManager(&tgid_list);   
	KVIDGridManager *gm = gIDGridManager; 
	KVList *grid_list = NULL;
	if(gm){
		grid_list = gm->GetGrids();
		grid_list->Disconnect("Modified()",gm,"Modified()");
	}
	// If the TGID of the global list is not in the sublist then
	// build grid
	TIter next(fIDGlobalList);
	Bool_t IDtypeOK = strcmp(idtype,"");
	KVTGID *tgid  = NULL;
	while( (tgid = (KVTGID *)next()) ){
		if(tgid_list.FindObject(tgid)) continue;

		if(IDtypeOK){
			KVBase *idt  = NULL;
                        TSeqCollection *idt_list = (TSeqCollection* )GetIDTelescopesForTGID(tgid);
			if(!idt_list) continue;
			if( !(idt = (KVBase *)idt_list->First()) ) continue;
			SafeDelete(idt_list);
			if( strcmp(idtype,idt->GetLabel()) ) continue;
		}
		// Not built grid for a KVTGID copy
		TString tmp = tgid->GetTitle();
		if(tmp.Contains("COPY")){
			tmp.Remove(0, tmp.Index("0x"));	
			KVTGID *tmp_tgid = reinterpret_cast<KVTGID *>((Int_t)tmp.Atof());
			Warning("KVRTGIDManager::BuildGridForAllTGID","No grid built for %s (%s, %p) because it is a copy of %s (%s, %p)"
					, tgid->GetName(), tgid->ClassName(), tgid
					, tmp_tgid->GetName(), tmp_tgid->ClassName(), tmp_tgid);
			continue;
		}
		KVTGIDGrid *grid = new KVTGIDGrid(tgid);
		grid->SetOnlyZId((Bool_t)tgid->GetZorA());
		if(tgid->GetZorA()) grid->SetMassFormula(tgid->GetMassFormula());
		grid->Generate(xmax, xmin, ID_min, ID_max, npoints, logscale);
		Info("KVRTGIDManager::BuildGridForAllTGID","grid built from its TGID function %s (%s, %p)"
				, tgid->GetName(), tgid->ClassName(), tgid);
	}
	if( grid_list ) grid_list->Connect("Modified()","KVIDGridManager",gm,"Modified()");
	gm->Modified();
}