예제 #1
0
bool	CTListBox::ProcessSelectable(UINT uiMsg,WPARAM wParam,LPARAM lParam)
{
	if( uiMsg == WM_KEYDOWN  )
	{
		switch( wParam )
		{
		case	VK_DOWN:
			{
				m_iSelectedItem++;
				if( m_iSelectedItem  >= GetMaximum() )
					m_iSelectedItem = GetMaximum() - 1;
				return true;
			}
			break;
		case VK_UP:
			{
				m_iSelectedItem--;
				if( m_iSelectedItem < 0 )
					m_iSelectedItem = 0;
				return true;
			}
			break;
		default:
			break;
		}
/*		case WM_MOUSEWHEEL:
			{
				RECT rc = { m_sPosition.x, m_sPosition.y, m_iWidth + m_sPosition.x, m_iHeight + m_sPosition.y
			}
		default:
			break;

		RECT rcModel = {0,0,0,0};
		
		if( m_pScrollModel )
		{
			rcModel = m_pScrollModel->GetWindowRect();
			if( PtInRect( &rcModel, ptMouse ) == 0 && !IsInside( ptMouse.x, ptMouse.y) )
				return 0;
		}
		int zDelta = (int)wParam;
		if( zDelta > 0)
			SetValue( --iValue );
		else
			SetValue( ++iValue );
		return uiMsg;*/
	}

	return false;
}
예제 #2
0
파일: hsum.C 프로젝트: ancapopescu13/root
// histograms filled and drawn in a loop
void hsum() {
//
// To see the output of this macro, click begin_html <a href="gif/hsum.gif" >here</a> end_html
//    Simple example illustrating how to use the C++ interpreter
//    to fill histograms in a loop and show the graphics results
//Author: Rene Brun

  TCanvas *c1 = new TCanvas("c1","The HSUM example",200,10,600,400);
  c1->SetGrid();

  gBenchmark->Start("hsum");

// Create some histograms.
  auto total  = new TH1F("total","This is the total distribution",100,-4,4);
  auto main   = new TH1F("main","Main contributor",100,-4,4);
  auto s1     = new TH1F("s1","This is the first signal",100,-4,4);
  auto s2     = new TH1F("s2","This is the second signal",100,-4,4);
  total->Sumw2();  // store the sum of squares of weights
  total->SetMarkerStyle(21);
  total->SetMarkerSize(0.7);
  main->SetFillColor(16);
  s1->SetFillColor(42);
  s2->SetFillColor(46);
  TSlider *slider = 0;

// Fill histograms randomly
  gRandom->SetSeed();
  const Int_t kUPDATE = 500;
  Float_t xs1, xs2, xmain;
  for ( Int_t i=0; i<10000; i++) {
     xmain = gRandom->Gaus(-1,1.5);
     xs1   = gRandom->Gaus(-0.5,0.5);
     xs2   = gRandom->Landau(1,0.15);
     main->Fill(xmain);
     s1->Fill(xs1,0.3);
     s2->Fill(xs2,0.2);
     total->Fill(xmain);
     total->Fill(xs1,0.3);
     total->Fill(xs2,0.2);
     if (i && (i%kUPDATE) == 0) {
        if (i == kUPDATE) {
           total->Draw("e1p");
           main->Draw("same");
           s1->Draw("same");
           s2->Draw("same");
           c1->Update();
           slider = new TSlider("slider",
              "test",4.2,0,4.6,total->GetMaximum(),38);
           slider->SetFillColor(46);
        }
        if (slider) slider->SetRange(0,Float_t(i)/10000.);
        c1->Modified();
        c1->Update();
     }
  }
  slider->SetRange(0,1);
  total->Draw("sameaxis"); // to redraw axis hidden by the fill area
  c1->Modified();
  gBenchmark->Show("hsum");
}
예제 #3
0
void MgFeatureNumericFunctions::CalculateDistribution(VECTOR_INT64& values, VECTOR_INT64& distValues)
{
    INT32 funcCode = -1;
    // Get the arguments from the FdoFunction
    bool supported = MgServerFeatureUtil::FindCustomFunction(m_customFunction, funcCode);

    if (supported)
    {
        switch(funcCode)
        {
            case MINIMUM:
            {
                GetMinimum(values, distValues);
                break;
            }
            case MAXIMUM:
            {
                GetMaximum(values, distValues);
                break;
            }
            case UNIQUE:
            {
                MgUniqueFunction<INT64>::Execute(values, distValues);
                break;
            }
        }
    }
}
예제 #4
0
// -----------------------------------------------------------------------------
//	StillTracking
// -----------------------------------------------------------------------------
//	Called during tracking.
//
OSStatus TValuePictControl::StillTracking(TCarbonEvent&inEvent, HIPoint& from)
{
    HIPoint mouse;
    float deltaX, deltaY;
    SInt32 mini, maxi;

    mini = GetMinimum();
    maxi = GetMaximum();

    inEvent.GetParameter<HIPoint>( kEventParamWindowMouseLocation, typeHIPoint, &mouse );
    ConvertToLocal(mouse);

    SInt32 curVal = GetValue();
    deltaX = mouse.x-from.x;
    deltaY = mouse.y-from.y;

    SInt32 val = SInt32(rint(curVal + (deltaX - deltaY) * (maxi - mini) / 300.));
    if ( val > maxi) val = maxi;
    if ( val < mini) val = mini;
    if (val != curVal) {
		SetValue ( val );
		from = mouse;
    }
    return noErr;
}
예제 #5
0
void CTListBox::SetValue( int i )
{
	if( GetMaximum() <=  m_nMaxLnCnt )
	{
		m_nPutLnNum = 0;
	}
	else if( i > GetMaximum() - m_nMaxLnCnt )
	{
		m_nPutLnNum = GetMaximum() - m_nMaxLnCnt;
	}
	else
	{
		m_nPutLnNum = i;
	}

	if( m_nPutLnNum < 0 )	
		m_nPutLnNum  = 0 ;

}
예제 #6
0
void CTree::SetValue( int i )
{
	m_iValue = i;
	m_iMaximum = GetMaximum();
	if( m_iValue < 0 )
		m_iValue = 0;
	else if( m_iValue + m_iExtent > m_iMaximum )
		m_iValue = m_iMaximum - m_iExtent;

}
예제 #7
0
///한라인에 표시할수 있는 최대문자길이보다 크면 잘라서 추가한다.
void CTListBox::AppendText(const char* szTxt,D3DCOLOR dwColor,bool bAutoIncValue )
{
	if( szTxt == NULL )
		return;

	///최대 아이템수를 넘으면 제일먼저 들어온 아이템을 버린다.
	if( (m_iMaxSize > 0) && !m_ITM.empty() && (m_iMaxSize <= (int)m_ITM.size()) )
		m_ITM.pop_front();

	t_list_item itm;	
	itm.m_bDrawn = false;
	int iLen = (int)strlen( szTxt );


	CTSplitString szString;	
	SIZE szSize = szString.GetSizeText( m_iFont, szTxt );
	
	//홍근 :
	if( szSize.cx <= m_iWidth )
	//if( iLen <= m_nMaxPutChar )
	{
		strcpy(itm.m_szTxt,szTxt);
		itm.m_dwColor = dwColor;
		m_ITM.push_back(itm);
	}
	else
	{
		if( m_nMaxPutChar <= 0 )
		{
			strcpy( itm.m_szTxt,szTxt );
			itm.m_dwColor = dwColor;
			m_ITM.push_back(itm);

		}
		else
		{
			CTSplitString TempString( m_iFont, (char*)szTxt, m_iWidth ,CTControlMgr::GetInstance()->GetCodePage() );
			for( int i = 0; i < TempString.GetLineCount(); ++i )
			{
				strcpy( itm.m_szTxt, TempString.GetString( i ));
				itm.m_dwColor = dwColor;
				m_ITM.push_back(itm);
			}
		}
	}
	if( bAutoIncValue )
		SetValue( GetMaximum() );
}
/**
 Method  : int EditUnsignedWnd::OnCreate(LPCREATESTRUCT lpCreateStruct)
 Purpose : Create the text box and the spin button control.
 Version : 1.0.0
*/
int EditUnsignedWnd::OnCreate(LPCREATESTRUCT lpCreateStruct) {
	if (Wnd::OnCreate(lpCreateStruct) == -1)	return -1;
	if (edit.IsNull()) return -1;

	upDown = new CSpinButtonCtrl;
	if (upDown.IsNull()) return -1;
	
	CRect wndRect;
	GetClientRect(wndRect);

	if (!edit->Create(wndRect, this)) return -1;
	if (!upDown->Create(UDS_AUTOBUDDY | WS_VISIBLE | WS_CHILD | UDS_SETBUDDYINT | UDS_NOTHOUSANDS | UDS_ALIGNRIGHT, wndRect, this, 0)) return -1;
	upDown->SetRange(0, (short) GetMaximum());

	return 0;
}
예제 #9
0
void checkpthat(TString fnameevt, TString filename, TString prefix, TString jtptvar)
{
  TFile *f = new TFile(fnameevt);
  auto nt = (TTree *)f->Get("nt");

  auto h = geth(prefix+"mcpthat", 80, 0, 400);
  nt->Project(h->GetName(),"pthat","");


  int minbin = nt->GetMinimum("pthatbin");
  int maxbin = nt->GetMaximum("pthatbin");
  //assumes ints between min and max

  int N = maxbin-minbin+1;

  vector<TString> pthatcuts;
  pthatcuts = {"pthat>30 && pthat<50","pthat>50 && pthat<80","pthat>80 && pthat<120","pthat>120"};
  auto hs = getstack(nt, prefix+"mcpthatstack","pthat",pthatcuts,80,0,400);
  hs->SetMinimum(1E-2);

  fout->cd();
  hs->Write();
  h->Write();

  f->Close();

  f = new TFile(filename);
  nt = (TTree *)f->Get("nt");

  auto hj = geth(prefix+"mcjtpt", 80, 0, 400);
  nt->Project(hj->GetName(),jtptvar,"weight*(subid==0)",jtptvar);

  
  vector<TString> jtptcuts;
  jtptcuts = {"pthat>30 && pthat<50 && subid==0","pthat>50 && pthat<80 && subid==0","pthat>80 && pthat<120 && subid==0","pthat>120 && subid==0"};
  //  for (int i=0;i<N;i++) jtptcuts.push_back(Form("pthatbin==%d",i));
  auto hsjtpt = getstack(nt, prefix+"mcjtptstack",jtptvar,jtptcuts,80,0,400);
  hsjtpt->SetMinimum(1E-2);

  fout->cd();
  hsjtpt->Write();
  hj->Write();
  //  fout->Write();
  
  f->Close();
}
예제 #10
0
//-----------------------------------------------------------------------------------
//	ValueChanged
//-----------------------------------------------------------------------------------
void TMultiPane::ValueChanged()
{
	HIViewRef subPane;
	SInt32 value = GetValue();
	SInt32 min = GetMinimum();
	SInt32 max = GetMaximum();

	for (SInt32 i = min; i <= max; ++i) {
		HIViewID id = { kSubPanelSignature + mID, i };
		OSStatus result = HIViewFindByID(GetViewRef(), id, &subPane);
		if (result == noErr) {
			HIViewSetVisible( subPane, false);
                }
	}
	HIViewID id = { kSubPanelSignature + mID, value };
	OSStatus result = HIViewFindByID(GetViewRef(), id, &subPane);
	if (result == noErr) {
		HIViewSetVisible( subPane, true);
        }  
	Invalidate();
}
CPLErr VRTSourcedRasterBand::ComputeRasterMinMax( int bApproxOK, double* adfMinMax )
{
    double  dfMin = 0.0;
    double  dfMax = 0.0;

/* -------------------------------------------------------------------- */
/*      Does the driver already know the min/max?                       */
/* -------------------------------------------------------------------- */
    if( bApproxOK )
    {
        int          bSuccessMin, bSuccessMax;

        dfMin = GetMinimum( &bSuccessMin );
        dfMax = GetMaximum( &bSuccessMax );

        if( bSuccessMin && bSuccessMax )
        {
            adfMinMax[0] = dfMin;
            adfMinMax[1] = dfMax;
            return CE_None;
        }
    }
    
/* -------------------------------------------------------------------- */
/*      If we have overview bands, use them for min/max.                */
/* -------------------------------------------------------------------- */
    if ( bApproxOK && GetOverviewCount() > 0 && !HasArbitraryOverviews() )
    {
        GDALRasterBand *poBand;

        poBand = GetRasterSampleOverview( GDALSTAT_APPROX_NUMSAMPLES );

        if ( poBand != this )
            return poBand->ComputeRasterMinMax( FALSE, adfMinMax );
    }
    
/* -------------------------------------------------------------------- */
/*      Try with source bands.                                          */
/* -------------------------------------------------------------------- */
    if ( bAntiRecursionFlag )
    {
        CPLError( CE_Failure, CPLE_AppDefined,
                  "VRTSourcedRasterBand::ComputeRasterMinMax() called recursively on the same band. "
                  "It looks like the VRT is referencing itself." );
        return CE_Failure;
    }
    bAntiRecursionFlag = TRUE;

    adfMinMax[0] = 0.0;
    adfMinMax[1] = 0.0;
    for( int iSource = 0; iSource < nSources; iSource++ )
    {
        double adfSourceMinMax[2];
        CPLErr eErr = papoSources[iSource]->ComputeRasterMinMax(GetXSize(), GetYSize(), bApproxOK, adfSourceMinMax);
        if (eErr != CE_None)
        {
            eErr = GDALRasterBand::ComputeRasterMinMax(bApproxOK, adfMinMax);
            bAntiRecursionFlag = FALSE;
            return eErr;
        }

        if (iSource == 0 || adfSourceMinMax[0] < adfMinMax[0])
            adfMinMax[0] = adfSourceMinMax[0];
        if (iSource == 0 || adfSourceMinMax[1] > adfMinMax[1])
            adfMinMax[1] = adfSourceMinMax[1];
    }

    bAntiRecursionFlag = FALSE;

    return CE_None;
}
float CCryptoBoolFunctionAnalyzer::GetNonLinearity(int coordinateFunction) const
{
    auto nonLinearity = pow(2, m_engine.GetGeneratorDegree() - 2) - GetMaximum(m_walshTable[coordinateFunction]) / 2.;
    return nonLinearity;
}
예제 #13
0
void MgFeatureNumericFunctions::CalculateDistribution(VECTOR& values, VECTOR& distValues)
{
    STRING funcName;
    int numCats;
    double dataMin, dataMax;
    INT32 funcCode = -1;

    // Get the arguments from the FdoFunction
    STRING propertyName;
    bool supported = MgServerFeatureUtil::FindCustomFunction(m_customFunction, funcCode);

    if (supported)
    {
        switch(funcCode)
        {
            case EQUAL_CATEGORY: // Equal Category
            {
                MgServerFeatureUtil::GetArguments(m_customFunction, propertyName, numCats, dataMin, dataMax, m_type);
                GetEqualCategories(values, numCats, dataMin, dataMax, distValues);
                break;
            }
            case STDEV_CATEGORY: // StdDev Category
            {
                MgServerFeatureUtil::GetArguments(m_customFunction, propertyName, numCats, dataMin, dataMax, m_type);
                GetStandardDeviationCategories(values, numCats, dataMin, dataMax, distValues);
                break;
            }
            case QUANTILE_CATEGORY: // Quantile Category
            {
                MgServerFeatureUtil::GetArguments(m_customFunction, propertyName, numCats, dataMin, dataMax, m_type);
                GetQuantileCategories(values, numCats, dataMin, dataMax, distValues);
                break;
            }
            case JENK_CATEGORY: // Jenk Category
            {
                MgServerFeatureUtil::GetArguments(m_customFunction, propertyName, numCats, dataMin, dataMax, m_type);
                GetJenksCategories(values, numCats, dataMin, dataMax, distValues);
                break;
            }
            case MINIMUM:
            {
                GetMinimum(values,distValues);
                break;
            }
            case MAXIMUM:
            {
                GetMaximum(values,distValues);
                break;
            }
            case MEAN:
            {
                GetMeanValue(values,distValues);
                break;
            }
            case STANDARD_DEV:
            {
                GetStandardDeviation(values,distValues);
                break;
            }
            case UNIQUE:
            {
                MgUniqueFunction<double>::Execute(values, distValues);
                break;
            }
        }
    }
}
예제 #14
0
bool CTListBox::IsLastItemDrawn()
{
	t_list_item	item = GetItem( GetMaximum() - 1);
	return item.m_bDrawn;
}
예제 #15
0
 void AARect::Translate(const Vector2 &translation)
 {
    SetExtents(GetMinimum() + translation, GetMaximum() + translation);
 }
예제 #16
0
std::string CGUISpinControl::GetDescription() const
{
  return StringUtils::Format("%i/%i", 1 + GetValue(), GetMaximum());
}
예제 #17
0
int main(int argc, char** argv)
{
  setTDRStyle();
  gStyle -> SetOptFit(0000);
  
  int nFib = 64;
  int nCryst = 9;
  
  std::string inFileName(argv[1]);
  
  
  //----------
  // open file
  
  TFile* inFile = TFile::Open(Form("ntuples/tot_capture_%s.root",inFileName.c_str()));
  TTree* tree = (TTree*)( inFile->Get("tree") );
  
  
  //---------------------
  // set branch addresses
  
  std::map<int,std::vector<int>*> t_waveform;
  std::map<int,std::vector<int>*> t_crystWaveform;
  
  for(int fibIt = 0; fibIt < nFib; ++fibIt)
  {
    t_waveform[fibIt] = new std::vector<int>;
    tree -> SetBranchAddress(Form("fib%02d_waveform",fibIt),&t_waveform[fibIt]);
  }
  for(int crystIt = 0; crystIt < nCryst; ++crystIt)
  {
    t_crystWaveform[crystIt] = new std::vector<int>;
    tree -> SetBranchAddress(Form("cryst%01d_waveform",crystIt),&t_crystWaveform[crystIt]);
  }
  
  
  
  //-------------
  // define plots
  
  std::map<int,int> n_waveform_fib;
  TGraph** g_waveform_fib = new TGraph*[nFib];
  
  std::map<int,int> n_waveform_cut_fib;
  TGraph** g_waveform_cut_fib = new TGraph*[nFib];
  
  TH1F** h_ped_fib = new TH1F*[nFib];
  TH1F* h_ped_fib_all = new TH1F("h_ped_fib_all","",100,80.,120.);
  
  TH1F** h_maximum_fib = new TH1F*[nFib];
  TH1F* h_maximum_fib_all = new TH1F("h_maximum_fib_all","",1000,0.,2500.);
  
  for(int fibIt = 0; fibIt < nFib; ++fibIt)
  {
    g_waveform_fib[fibIt] = new TGraph();
    g_waveform_cut_fib[fibIt] = new TGraph();
    
    h_ped_fib[fibIt] = new TH1F(Form("h_ped_fib%02d",fibIt),"",100,80.,120.);
    h_maximum_fib[fibIt] = new TH1F(Form("h_maximum_fib%02d",fibIt),"",1000,0.,2500.);
  }
  
  TProfile2D* p_fibAveInt = new TProfile2D("p_fibAveInt","",17,-0.5,16.5,18,-0.5,17.5);
  TProfile2D* p_fibAveMax = new TProfile2D("p_fibAveMax","",17,-0.5,16.5,18,-0.5,17.5);
  TProfile2D* p_crystAveMax = new TProfile2D("p_crystAveMax","",3,-0.5,2.5,3,-0.5,2.5);
  
  TH1F* h_tot_integral = new TH1F("h_tot_integral","",1000,0.,100000.);
  TH1F* h_tot_maximum  = new TH1F("h_tot_maximum", "",1000,0.,1000.);
  
  
  //------------------
  // loop over entries
  
  for(int entry = 0; entry < tree->GetEntries(); ++entry)
  {
    std::cout << ">>> reading entry " << entry << " / " << tree->GetEntries() << "\r" << std::flush;
    tree -> GetEntry(entry);
    
    float tot_integral = 0.;
    float tot_maximum = 0.;
    
    for(int fibIt = 0; fibIt < nFib; ++fibIt)
    {
      ++n_waveform_fib[fibIt];
      AddWaveform(g_waveform_fib[fibIt],t_waveform[fibIt]);
      
      float ped, integral, maximum;
      CalculateAmplitude(t_waveform[fibIt],ped,integral,maximum);
      
      h_ped_fib[fibIt] -> Fill(ped);
      h_ped_fib_all -> Fill(ped);
      h_maximum_fib[fibIt] -> Fill(maximum);
      h_maximum_fib_all -> Fill(maximum);
      
      int x = 16-2*int(fibIt/8);
      int y = (x/2)%2 == 0 ? 16-2*(fibIt%8) : 16-2*(fibIt%8)-1;
      p_fibAveInt -> Fill(x,y,integral);
      p_fibAveMax -> Fill(x,y,maximum);
      
      if( maximum+ped > 120. )
      {
        tot_integral += integral;
        tot_maximum += maximum;
        
        ++n_waveform_cut_fib[fibIt];
        AddWaveform(g_waveform_cut_fib[fibIt],t_waveform[fibIt]);
      }
    }
    
    for(int crystIt = 0; crystIt < nCryst; ++crystIt)
    {
      float ped, integral, maximum;
      CalculateAmplitude(t_waveform[crystIt],ped,integral,maximum);
      p_crystAveMax -> Fill(crystIt%3,2-crystIt/3,maximum);
    }
    
    h_tot_integral -> Fill(tot_integral);
    h_tot_maximum -> Fill(tot_maximum);
  }
  
  
  
  TCanvas* c_waveform_fib_all = new TCanvas();
  
  int plotIt = 0;
  float min = +999999.;
  float max = -999999.;
  
  for(int fibIt = 0; fibIt < nFib; ++fibIt)
  {
    TGraph* g = g_waveform_fib[fibIt];
    if( g->GetN() == 0 ) continue;
    
    NormalizeGraph(g,n_waveform_fib[fibIt]);
    
    if( GetMinimum(g) < min ) min = GetMinimum(g);
    if( GetMaximum(g) > max ) max = GetMaximum(g);
  }
  
  for(int fibIt = 0; fibIt < nFib; ++fibIt)
  {
    TGraph* g = g_waveform_fib[fibIt];
    if( g->GetN() == 0 ) continue;
    
    TCanvas* c_waveform_fib = new TCanvas();
    
    g -> SetMinimum(min-0.05*fabs(max-min));
    g -> SetMaximum(max+0.05*fabs(max-min));
    g -> SetLineWidth(2);
    g -> SetLineColor(fibIt+1);
    g -> SetMarkerSize(0.2);
    g -> GetXaxis() -> SetTitle("sample time (ns)");
    g -> Draw("APL");
    
    c_waveform_fib -> Print(Form("/afs/cern.ch/user/a/abenagli/www/TBatFNAL/%s/plotsPerFib/waveform_fib%02d.png",inFileName.c_str(),fibIt),"png");
    
    c_waveform_fib_all -> cd();
    
    if( plotIt == 0 ) g -> Draw("APL");
    else              g -> Draw("PL,same");
    
    ++plotIt;
  }
  
  c_waveform_fib_all -> Print(Form("/afs/cern.ch/user/a/abenagli/www/TBatFNAL/%s/waveform_fib_all.png",inFileName.c_str()),"png");
  
  
  
  TCanvas* c_waveform_cut_fib_all = new TCanvas();
  
  plotIt = 0;
  min = +999999.;
  max = -999999.;
  
  for(int fibIt = 0; fibIt < nFib; ++fibIt)
  {
    TGraph* g = g_waveform_cut_fib[fibIt];
    if( g->GetN() == 0 ) continue;
    
    NormalizeGraph(g,n_waveform_cut_fib[fibIt]);
    
    if( GetMinimum(g) < min ) min = GetMinimum(g);
    if( GetMaximum(g) > max ) max = GetMaximum(g);
  }
  
  for(int fibIt = 0; fibIt < nFib; ++fibIt)
  {
    TGraph* g = g_waveform_cut_fib[fibIt];
    if( g->GetN() == 0 ) continue;
    
    //g -> SetMinimum(min-0.05*fabs(max-min));
    //g -> SetMaximum(max+0.05*fabs(max-min));
    g -> SetLineWidth(2);
    g -> SetLineColor(fibIt+1);
    g -> SetMarkerSize(0.2);
    g -> GetXaxis() -> SetTitle("sample time (ns)");
    g -> Draw("APL");
    
    c_waveform_cut_fib_all -> cd();
    
    if( plotIt == 0 ) g -> Draw("APL");
    else              g -> Draw("PL,same");
    
    ++plotIt;
  }
  
  c_waveform_cut_fib_all -> Print(Form("/afs/cern.ch/user/a/abenagli/www/TBatFNAL/%s/waveform_cut_fib_all.png",inFileName.c_str()),"png");
  
  
  
  for(int fibIt = 0; fibIt < nFib; ++fibIt)
  {
    TH1F* h = h_ped_fib[fibIt];
    
    TCanvas* c_ped_fib = new TCanvas();
    c_ped_fib -> SetLogy();
    
    h -> SetLineWidth(2);
    h -> GetXaxis() -> SetTitle("max sample");
    h -> Draw();
    h -> Fit("gaus","Q");
    
    TLatex* latex1 = new TLatex(0.60,0.90,Form("RMS = %.1f",h->GetRMS()));
    latex1 -> SetNDC();
    latex1 -> SetTextFont(42);
    latex1 -> SetTextSize(0.04);
    latex1 -> Draw("same");
    
    TLatex* latex2 = new TLatex(0.60,0.85,Form("#sigma = %.1f",h->GetFunction("gaus")->GetParameter(2)));
    latex2 -> SetNDC();
    latex2 -> SetTextFont(42);
    latex2 -> SetTextSize(0.04);
    latex2 -> Draw("same");
    
    c_ped_fib -> Print(Form("/afs/cern.ch/user/a/abenagli/www/TBatFNAL/%s/plotsPerFib/ped_fib%02d.png",inFileName.c_str(),fibIt),"png");
    
    h = h_maximum_fib[fibIt];
    
    TCanvas* c_maximum_fib = new TCanvas();
    c_maximum_fib -> SetLogy();
    
    h -> SetLineWidth(2);
    h -> GetXaxis() -> SetTitle("max sample");
    h -> Draw();
    
    c_maximum_fib -> Print(Form("/afs/cern.ch/user/a/abenagli/www/TBatFNAL/%s/plotsPerFib/maximum_fib%02d.png",inFileName.c_str(),fibIt),"png");
  }
  
  TCanvas* c_ped_fib_all = new TCanvas();
  c_ped_fib_all -> SetLogy();
  
  h_ped_fib_all -> SetLineWidth(2);
  h_ped_fib_all -> GetXaxis() -> SetTitle("pedestal");
  h_ped_fib_all -> Draw();
  h_ped_fib_all -> Fit("gaus","Q");
  
  TLatex* latex1 = new TLatex(0.60,0.90,Form("RMS = %.1f",h_ped_fib_all->GetRMS()));
  latex1 -> SetNDC();
  latex1 -> SetTextFont(42);
  latex1 -> SetTextSize(0.04);
  latex1 -> Draw("same");
  
  TLatex* latex2 = new TLatex(0.60,0.85,Form("#sigma = %.1f",h_ped_fib_all->GetFunction("gaus")->GetParameter(2)));
  latex2 -> SetNDC();
  latex2 -> SetTextFont(42);
  latex2 -> SetTextSize(0.04);
  latex2 -> Draw("same");
  c_ped_fib_all -> Print(Form("/afs/cern.ch/user/a/abenagli/www/TBatFNAL/%s/ped_fib_all.png",inFileName.c_str()),"png");
  
  TCanvas* c_maximum_fib_all = new TCanvas();
  c_maximum_fib_all -> SetLogy();
  
  h_maximum_fib_all -> SetLineWidth(2);
  h_maximum_fib_all -> GetXaxis() -> SetTitle("max sample");
  h_maximum_fib_all -> Draw();
  
  c_maximum_fib_all -> Print(Form("/afs/cern.ch/user/a/abenagli/www/TBatFNAL/%s/maximum_fib_all.png",inFileName.c_str()),"png");
  
  
  
  TCanvas* c_fibAveInt = new TCanvas();
  
  p_fibAveInt -> Draw("COLZ");
  c_fibAveInt -> Print(Form("/afs/cern.ch/user/a/abenagli/www/TBatFNAL/%s/fibAveInt.png",inFileName.c_str()),"png");
  
  TCanvas* c_fibAveMax = new TCanvas();
  
  p_fibAveMax -> Draw("COLZ");
  c_fibAveMax -> Print(Form("/afs/cern.ch/user/a/abenagli/www/TBatFNAL/%s/fibAveMax.png",inFileName.c_str()),"png");
  
  
  TCanvas* c_crystAveMax = new TCanvas();
  
  p_crystAveMax -> Draw("COLZ");
  c_crystAveMax -> Print(Form("/afs/cern.ch/user/a/abenagli/www/TBatFNAL/%s/crystAveMax.png",inFileName.c_str()),"png");
  
  
  
  TCanvas* c_tot_integral = new TCanvas();
  c_tot_integral -> SetLogy();
  
  h_tot_integral -> Draw();
  c_tot_integral -> Print(Form("/afs/cern.ch/user/a/abenagli/www/TBatFNAL/%s/tot_integral.png",inFileName.c_str()),"png");
  
  TCanvas* c_tot_maximum = new TCanvas();
  c_tot_maximum -> SetLogy();
  
  h_tot_maximum -> Draw();
  c_tot_maximum -> Print(Form("/afs/cern.ch/user/a/abenagli/www/TBatFNAL/%s/tot_maximum.png",inFileName.c_str()),"png");
}
예제 #18
0
void GDALTerrain::init()
{
    dataset = (GDALDataset*) GDALOpen(gdalFile.c_str(), GA_ReadOnly);

    if(dataset == nullptr) {
        std::cerr << "Unable to open GDAL File: " << gdalFile << std::endl;
        exit(1);
    }

    auto raster = dataset->GetRasterBand(1);

    width = raster->GetXSize();
    height = raster->GetYSize();

    int gotMin, gotMax;
    float min = (float) raster->GetMinimum(&gotMin);
    float max = (float) raster->GetMaximum(&gotMax);

    double minMax[2] = {min, max};

    if(!(gotMin && gotMax)) {
        GDALComputeRasterMinMax((GDALRasterBandH) raster, TRUE, minMax);
        min = (float) minMax[0];
        max = (float) minMax[1];
    }

    if(Engine::getEngine()->getOptions().verbose) {
        std::cout << "terrain: " << gdalFile << " x: " << width << " y: " << height << "   min: " << min << " max: " << max << std::endl;
    }

    Vertex vert;

    vert.normal[0] = 0;
    vert.normal[1] = 1;
    vert.normal[2] = 0;

    float scale = Engine::getEngine()->getOptions().map_scalar;
    heightScale = 100.0f;

    gdal_data = std::vector<std::vector<float>>(height, std::vector<float>(width, 0.0f));

    float *lineData1 = new float[width];
    float *lineData2 = new float[width];

    float range = max - min;

    for(int z = 0; z < height-1; z++) {
        raster->RasterIO(GF_Read, 0, z, width, 1, lineData1, width, 1, GDT_Float32, 0, 0);
        raster->RasterIO(GF_Read, 0, z+1, width, 1, lineData2, width, 1, GDT_Float32, 0, 0);

        gdal_data[z].assign(lineData1, lineData1+width);
        gdal_data[z+1].assign(lineData2, lineData2+width);

        for(int x = 0; x < width-1; x++) {
            vert.pos[0] = x * scale;
            vert.pos[1] = heightScale * (lineData1[x]-min)/range;
            vert.pos[2] = z * scale;

            vert.texture[0] = x;// / float(width);
            vert.texture[1] = z;// / float(height);

            calcNormal(x, z, vert, min, range);

            geometry.push_back(vert);

            vert.pos[0] = (x+1) * scale;
            vert.pos[1] = heightScale * (lineData1[x+1]-min)/range;
            vert.pos[2] = z * scale;

            vert.texture[0] = (x+1);// / float(width);
            vert.texture[1] = z;// / float(height);

            calcNormal(x, z, vert, min, range);

            geometry.push_back(vert);

            vert.pos[0] = x * scale;
            vert.pos[1] = heightScale * (lineData2[x]-min)/range;
            vert.pos[2] = (z+1) * scale;

            vert.texture[0] = x;// / float(width);
            vert.texture[1] = (z+1);// / float(height);

            calcNormal(x, z, vert, min, range);

            geometry.push_back(vert);



            vert.pos[0] = x * scale;
            vert.pos[1] = heightScale * (lineData2[x]-min)/range;
            vert.pos[2] = (z+1) * scale;

            vert.texture[0] = x;// / float(width);
            vert.texture[1] = (z+1);// / float(height);

            calcNormal(x, z, vert, min, range);

            geometry.push_back(vert);

            vert.pos[0] = (x+1) * scale;
            vert.pos[1] = heightScale * (lineData2[x+1]-min)/range;
            vert.pos[2] = (z+1) * scale;

            vert.texture[0] = (x+1);// / float(width);
            vert.texture[1] = (z+1);// / float(height);

            calcNormal(x, z, vert, min, range);

            geometry.push_back(vert);

            vert.pos[0] = (x+1) * scale;
            vert.pos[1] = heightScale * (lineData1[x+1]-min)/range;
            vert.pos[2] = z * scale;

            vert.texture[0] = (x+1);// / float(width);
            vert.texture[1] = z;// / float(height);

            calcNormal(x, z, vert, min, range);

            geometry.push_back(vert);

        }
    }

   // for(int i = 0; i < geometry.size(); i++) {
     //   if(i % 6 == 0)
       // std::cout << i << ": " << geometry[i].pos[1] << std::endl;
    //}

    std::cout << "size: " << geometry.size() << std::endl;

    delete[] lineData1;
    delete[] lineData2;

    Vertex *geo = geometry.data();

    glGenVertexArrays(1, &vao);
    glBindVertexArray(vao); 
    glGenBuffers(1, &vbo);

    glBindBuffer(GL_ARRAY_BUFFER, vbo);
    glBufferData(GL_ARRAY_BUFFER, sizeof(Vertex) * geometry.size(), geo, GL_STATIC_DRAW);

    glEnableVertexAttribArray(0);
    glVertexAttribPointer(program->getLocation("vs_pos"),
            3,
            GL_FLOAT,
            GL_FALSE,
            sizeof(Vertex),
            (void*)offsetof(Vertex,pos));

    glEnableVertexAttribArray(1);
    glVertexAttribPointer(program->getLocation("vs_norm"),
            3,
            GL_FLOAT,
            GL_FALSE,
            sizeof(Vertex),
            (void*)offsetof(Vertex,normal));

    glEnableVertexAttribArray(2);
    glVertexAttribPointer(program->getLocation("vs_uv"),
            2,
            GL_FLOAT,
            GL_FALSE,
            sizeof(Vertex),
            (void*)offsetof(Vertex,texture));

    texture = new Texture("../assets/desert.jpg", GL_TEXTURE_2D);

    //model = glm::translate(model, glm::vec3(width/2, 0, height/2));
}