Create a lattice around mu, sigma
This commit is contained in:
		
							parent
							
								
									2cb63ce971
								
							
						
					
					
						commit
						eeca7819af
					
				| 
						 | 
				
			
			@ -0,0 +1,49 @@
 | 
			
		|||
#ifndef Lattice_h
 | 
			
		||||
#define LAttice_h 1
 | 
			
		||||
 | 
			
		||||
#include <iostream>
 | 
			
		||||
#include <string>
 | 
			
		||||
#include <fstream>
 | 
			
		||||
#include <cmath>
 | 
			
		||||
 | 
			
		||||
#include "TMath.h"
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
//////////////////////////////////////////////////////////
 | 
			
		||||
//							//
 | 
			
		||||
//    Create a lattice around the estimated mu, sigma   //
 | 
			
		||||
//							//
 | 
			
		||||
//////////////////////////////////////////////////////////
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
typedef struct {
 | 
			
		||||
		
 | 
			
		||||
		Double_t mu = 0.0;
 | 
			
		||||
		Double_t sigma = 0.0;
 | 
			
		||||
	}MuSigma;
 | 
			
		||||
 | 
			
		||||
class Lattice{
 | 
			
		||||
 | 
			
		||||
public:	
 | 
			
		||||
	Lattice();
 | 
			
		||||
	~Lattice();
 | 
			
		||||
	
 | 
			
		||||
	void SetNop(Int_t num);
 | 
			
		||||
	void SetPercent(Int_t num);
 | 
			
		||||
	
 | 
			
		||||
	void SetLattice(Double_t mu_est, Double_t sigma_est);
 | 
			
		||||
	
 | 
			
		||||
	MuSigma GetMuSigma(Int_t index);
 | 
			
		||||
	
 | 
			
		||||
	
 | 
			
		||||
private:
 | 
			
		||||
	Int_t _nop; //number of points in [mu-_percent; mu+_percent]
 | 
			
		||||
	Double_t _percent; 
 | 
			
		||||
	
 | 
			
		||||
	std::vector<MuSigma> ms_vect;
 | 
			
		||||
	
 | 
			
		||||
 | 
			
		||||
};
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
#endif
 | 
			
		||||
| 
						 | 
				
			
			@ -0,0 +1,74 @@
 | 
			
		|||
#include "Lattice.hh"
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
Lattice::Lattice() : _nop(100), _percent(0.2){;}
 | 
			
		||||
 | 
			
		||||
Lattice::~Lattice(){;}
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
void Lattice::SetNop(Int_t num){
 | 
			
		||||
 | 
			
		||||
	_nop = num;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
void Lattice::SetPercent(Int_t num){
 | 
			
		||||
 | 
			
		||||
	if((num > 1) && (num <= 100))
 | 
			
		||||
		_percent = num/100.0;
 | 
			
		||||
	
 | 
			
		||||
	else
 | 
			
		||||
		std::cout << "Invalid value for percent, set to default" << std::endl;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
MuSigma Lattice::GetMuSigma(Int_t index){
 | 
			
		||||
	
 | 
			
		||||
	return ms_vect[index];
 | 
			
		||||
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
void Lattice::SetLattice(Double_t mu_est, Double_t sigma_est){
 | 
			
		||||
 | 
			
		||||
		Double_t loc_sigma, loc_mu;
 | 
			
		||||
		
 | 
			
		||||
		Double_t sigmin, sigmax, mumin, mumax;
 | 
			
		||||
		
 | 
			
		||||
		Double_t ds, dm;
 | 
			
		||||
		
 | 
			
		||||
		mumax = mu_est + mu_est*_percent;
 | 
			
		||||
		mumin = mu_est - mu_est*_percent;
 | 
			
		||||
		sigmax = sigma_est + sigma_est*_percent;
 | 
			
		||||
		sigmin = sigma_est - sigma_est*_percent;
 | 
			
		||||
		
 | 
			
		||||
		dm = (mumax-mumin) / _nop;
 | 
			
		||||
		ds = (sigmax-sigmin) / _nop;
 | 
			
		||||
		
 | 
			
		||||
		loc_mu = mumin;
 | 
			
		||||
		loc_sigma = sigmin;
 | 
			
		||||
			
 | 
			
		||||
		int i = 0;
 | 
			
		||||
		
 | 
			
		||||
		while(loc_mu <= mumax){
 | 
			
		||||
		
 | 
			
		||||
			ms_vect.push_back(MuSigma());
 | 
			
		||||
			
 | 
			
		||||
			ms_vect[i].mu = loc_mu;
 | 
			
		||||
			ms_vect[i].sigma = loc_sigma;
 | 
			
		||||
						
 | 
			
		||||
			i++;
 | 
			
		||||
			loc_mu += dm;
 | 
			
		||||
			loc_sigma += ds;
 | 
			
		||||
			
 | 
			
		||||
			
 | 
			
		||||
		}
 | 
			
		||||
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
		Loading…
	
		Reference in New Issue