示例#1
0
int main() {
	float x, y;
	float radius, theta;
	float degree;

	printf("Please enter the x and y coordinates for your point: ");
	scanf("%f%f", &x, &y);

	radius = getRadius(x, y);
	theta = getTheta(x, y);
	degree = theta * (180 / acos(-1)); // convert radians to degrees
		/*adjust degree value for the correct quadrant*/
		if(x < 0 && y > 0)
			degree = 180 + degree;
		else if(x < 0 && y < 0)
			degree = 180 + degree;
		else if(x > 0 && y < 0)
			degree = 360 +  degree;
		else if(x < 0 && y == 0)
			degree = 180;
		else if(x == 0 && y < 0)
			degree = 270;
	printf("The Cartesian coordinates (%.2f, %.2f) correspond to the polar coordinates (%.2f, %.2f).\nThe polar radius is %.2f and the polar angle is %.2f degrees.\n", x, y, radius, degree, radius, degree);
	getQuadrant(x, y);

	return 0;
}
示例#2
0
float getLFraction(const int nEvtSim, const float planeL)
{
  float nEvtPass = 0;

  std::cout << planeL << std::endl;

  const int fracSize = 10000;
  const float dimPlane = 10.0;
  const float rHemi = dimPlane/2.0*TMath::Sqrt(2.0);

  for(int genIter = 0; genIter < nEvtSim; genIter++){
    float phiHemi = getPhi(fracSize);
    float thetaHemi = getTheta(fracSize);
    float planeX1 = getPlanePos(fracSize, dimPlane);
    float planeY1 = getPlanePos(fracSize, dimPlane);

    float hemiX = rHemi*cos(thetaHemi)*cos(phiHemi);
    float hemiY = rHemi*cos(thetaHemi)*sin(phiHemi);
    float delL = rHemi*sin(thetaHemi);

    float delX = hemiX - planeX1;
    float delY = hemiY - planeY1;
    float delR = TMath::Sqrt(delX*delX + delY*delY);
    float trajPhi = TMath::ATan2(delY, delX);

    float rExit = getRExit(trajPhi, dimPlane, planeX1, planeY1);

    if((delL/delR)*rExit >= planeL) nEvtPass++;
  }

  return nEvtPass/((float)nEvtSim);
}
void AgentCore::dynamics() {
  double theta = getTheta(pose_.orientation);
  double x_dot_new = speed_command_sat_ * std::cos(theta);
  double y_dot_new = speed_command_sat_ * std::sin(theta);
  double theta_dot_new = speed_command_sat_ / vehicle_length_ * std::tan(steer_command_sat_);

  geometry_msgs::Pose pose_old = pose_;
  pose_.position.x = integrator(pose_.position.x, twist_.linear.x, x_dot_new, 1);
  pose_.position.y = integrator(pose_.position.y, twist_.linear.y, y_dot_new, 1);
  setTheta(pose_.orientation, integrator(theta, twist_.angular.z, theta_dot_new, 1));
  twist_.linear.x = x_dot_new;
  twist_.linear.y = y_dot_new;
  twist_.angular.z = theta_dot_new;

  std::stringstream s;
  s << "Pose (" << pose_.position.x << ", " << pose_.position.y << ").";
  console(__func__, s, DEBUG_VVV);
  s << "Twist (" << twist_.linear.x << ", " << twist_.linear.y << ").";
  console(__func__, s, DEBUG_VVV);
  s << "System state (" << x_dot_new << ", " << y_dot_new << ", " << theta_dot_new << ").";
  console(__func__, s, DEBUG_VVVV);

  broadcastPose(pose_, agent_frame_);
  broadcastPath(pose_, pose_old, agent_frame_);
}
示例#4
0
 std::string GammaDeviate::make_repr(bool incl_seed)
 {
     std::ostringstream oss(" ");
     oss << "galsim.GammaDeviate(";
     if (incl_seed) oss << seedstring(split(serialize(), ' ')) << ", ";
     oss << "k="<<getK()<<", ";
     oss << "theta="<<getTheta()<<")";
     return oss.str();
 }
示例#5
0
 std::vector<double> BlackScholesGreeks::getAllGreeks()
 {
     std::vector<double> data;
     data.push_back(getPremium());
     data.push_back(getDelta());
     data.push_back(getGamma());
     data.push_back(getVega());
     data.push_back(getRho());
     data.push_back(getTheta());
     return data;
 }
示例#6
0
EulerAngles::EulerAngles(const Dcm &dcm) :
	Vector(3)
{
	setTheta(asinf(-dcm(2, 0)));

	if (fabsf(getTheta() - M_PI_2_F) < 1.0e-3f) {
		setPhi(0.0f);
		setPsi(atan2f(dcm(1, 2) - dcm(0, 1),
			      dcm(0, 2) + dcm(1, 1)) + getPhi());

	} else if (fabsf(getTheta() + M_PI_2_F) < 1.0e-3f) {
		setPhi(0.0f);
		setPsi(atan2f(dcm(1, 2) - dcm(0, 1),
			      dcm(0, 2) + dcm(1, 1)) - getPhi());

	} else {
		setPhi(atan2f(dcm(2, 1), dcm(2, 2)));
		setPsi(atan2f(dcm(1, 0), dcm(0, 0)));
	}
}
//車体方向PID制御関数
S8 RA_directionCtrl_PID(float target) {
	static float bf_dev = 0.0;
	
	float dev = getTheta( ) - target;
	//float i_dev = i_dev + (dev * 0.0005);
	float d_dev = (dev - bf_dev) / 0.0005;
	bf_dev = dev;

	//S8 turn = Kp * dev + Ki * i_dev + Kd * d_dev;
	S8 turn = 1.0 * dev + 0.5 * d_dev;
	if (-100 > turn) {
		turn = -100;
	}
	else if (100 < turn) {
		turn = 100;
	}

	return turn;
}
示例#8
0
// modifies the main diagonal of the iteration matrix to introduce new dt
void FCT_Solver::initialize(double _dt, Options* options, Performance* pp)
{
    const real_t EPSILON = escript::DataTypes::real_t_eps();
    const_TransportProblem_ptr fctp(transportproblem);
    const index_t* main_iptr = fctp->borrowMainDiagonalPointer();
    const dim_t n = fctp->transport_matrix->getTotalNumRows();
    const double theta = getTheta();
    omega = 1. / (_dt * theta);
    dim_t i;
    Options options2;

    solve_free(fctp->iteration_matrix.get());
    //   fctp->iteration_matrix[i,i]=m[i]/(dt theta) -l[i,i]
    dt = _dt;
    #pragma omp parallel for private(i)
    for (i = 0; i < n; ++i) {
        const double m_i = fctp->lumped_mass_matrix[i];
        const double l_ii = fctp->main_diagonal_low_order_transport_matrix[i];
        if ( m_i > 0 ) {
            fctp->iteration_matrix->mainBlock->val[main_iptr[i]] = m_i * omega - l_ii;
        } else {
            fctp->iteration_matrix->mainBlock->val[main_iptr[i]] = std::abs(m_i * omega - l_ii)/(EPSILON*EPSILON);
        }
    }

    // allocate preconditioner/solver
    options2.verbose = options->verbose;
    if (method == PASO_LINEAR_CRANK_NICOLSON) {
        options2.preconditioner = PASO_GS;
    } else {
        options2.preconditioner = PASO_JACOBI;
        //options2.preconditioner = PASO_GS;
    }
    options2.use_local_preconditioner = false;
    options2.sweeps = -1;

    Performance_startMonitor(pp, PERFORMANCE_PRECONDITIONER_INIT);
    fctp->iteration_matrix->setPreconditioner(&options2);
    Performance_stopMonitor(pp, PERFORMANCE_PRECONDITIONER_INIT);
}
void AgentCore::guidance() {
  double los_distance = std::sqrt(std::pow(pose_virtual_.position.x - pose_.position.x, 2)
                                  + std::pow(pose_virtual_.position.y - pose_.position.y, 2));
  // std::atan2 automatically handle the los_distance == 0 case >> los_angle = 0
  double los_angle = std::atan2(pose_virtual_.position.y - pose_.position.y,
                                pose_virtual_.position.x - pose_.position.x);

  double speed_command = k_p_speed_*los_distance;
  speed_command_sat_ = saturation(speed_command, speed_min_, speed_max_);

  double steer_command = k_p_steer_*angles::shortest_angular_distance(getTheta(pose_.orientation), los_angle);
  steer_command_sat_ = saturation(steer_command, steer_min_, steer_max_);

  // there is no need to get sub-centimeter accuracy
  floor(speed_command_sat_, 1);

  std::stringstream s;
  s << "Guidance commands (" << speed_command_sat_ << ", " << steer_command_sat_ << ").";
  console(__func__, s, DEBUG_VV);
  s << "LOS distance and angle (" << los_distance << ", " << los_angle << ").";
  console(__func__, s, DEBUG_VVVV);
}
示例#10
0
文件: unit.cpp 项目: jruberg/COMP419
void Unit::path(std::list<Unit*>::iterator itr) {
	
	CIwFVec2 force = CIwFVec2::g_Zero;
	
	std::list<Unit*>* units = game->getUnits();
	float theta = getTheta();
	
	CIwFVec2 dirToward = CIwFVec2::g_Zero;
	Unit* curUnit;
	
	//brute force - need to take advantage of theta sorting
	for (itr = units->begin() ; itr != units->end(); ++itr) {
		curUnit = *(itr);
		
		if ((*itr) != this && THETA_DIFF(curUnit->getTheta(), theta) < PATH_THETA_RANGE) {
			dirToward = position - curUnit->getPosition();
			float dist = dirToward.GetLengthSquared();
			force += dirToward.GetNormalised() * (curUnit->getSize()*REPEL_FACTOR / pow(dist, 1.875));
            // We can tweak bottom factor later, this seems to work fine:           ^
		}
	}
		
	//attractive force for opponent leader
	Player* opponent = game->getLocalPlayer() != owner ? owner : game->getOpponentPlayer();
	dirToward = ((Unit*)(opponent->getLeader()))->getPosition() - position;
	float dist = dirToward.GetLength();

    if(dist > 0)
        force += dirToward.GetNormalised() * (LEADER_ATTRACTION / dist);	
	
	//"spring" force to motivate circular pathing
	float centerR = (game->getWorldRadius().y + game->getWorldRadius().x)/2.0;
	float rDiff = centerR - r;
	force += position * ((rDiff < 0 ? -1 : 1) * WALL_REPEL * SQ(rDiff)); // Ternary is experimentally faster
			
	velocity = speed*force.GetNormalised();
	setPosition(position + velocity);
}
示例#11
0
double Calculator::getIntensity(double Q)
{
	std::complex<double> cppf1, cppf2;
	gsl_complex alpha, beta;
	gsl_complex gslf1, gslf2;
	int s;
	double avFactor;

	cppf1 = m_sf1->F(0.0, 0.0, Q, m_energy);
	cppf2 = m_sf2->F(0.0, 0.0, Q, m_energy);

	gslf1 = gsl_complex_rect(cppf1.real(), cppf1.imag());
	gslf2 = gsl_complex_rect(cppf2.real(), cppf2.imag());

	avFactor = exp(-2.0 / m_N);

	alpha = gsl_complex_rect (1.0, 0.0);
	beta = gsl_complex_rect (0.0, 0.0);

	/*set vector F (scattering factors)*/
	gsl_vector_complex_set(F, 0, gslf1);
	gsl_vector_complex_set(F, 1, gslf2);

	/*set vector conj(F) (scattering factors)*/
	gsl_vector_complex_set(Fconj, 0, gsl_complex_conjugate(gslf1));
	gsl_vector_complex_set(Fconj, 1, gsl_complex_conjugate(gslf2));

	/*set exp matrix*/
	setMatrixExp(m_Exp, Q);

	/*find W = P * Exp * Ps * conj(F)  vector:*/
	/* (1) W = alpha * Ps * conj(F) + beta * W */
	gsl_blas_zgemv (CblasNoTrans, alpha, m_Ps, Fconj, beta, W);

	/*printf("W(1):\n");
	gsl_vector_complex_fprintf (stdout, W, "%g");*/

	/* (2) W = alpha * Exp * tmp_vec + beta * W */
	gsl_blas_zgemv (CblasNoTrans, alpha, m_Exp, W, beta, tmp_vec);

	/*printf("W(2):\n");
	gsl_vector_complex_fprintf (stdout, tmp_vec, "%g");*/

	/* (3) W = alpha * P * tmp_vec + beta * W */
	gsl_blas_zgemv (CblasNoTrans, alpha, m_P, tmp_vec, beta, W);

	/*Find J0 = F.(Ps * conj(F)) */
	gsl_blas_zgemv (CblasNoTrans, alpha, m_Ps, Fconj, beta, tmp_vec);
	gsl_blas_zdotu (F, tmp_vec, &J0);

	/*alpha = exp(-2 / N)*/
	alpha = gsl_complex_rect (avFactor, 0.0);
	beta = gsl_complex_rect (0.0, 0.0);

	/*find T matrix: T = alpha * P * exp + beta * T*/
	gsl_blas_zgemm (CblasNoTrans, CblasNoTrans, alpha, m_P, m_Exp, beta, T);

	/*printf("T:\n");
	gsl_matrix_complex_fprintf (stdout, T, "%g");*/

	/*Find Jns = F. (G * W)  */
	/*tmp_mat = I */
	gsl_matrix_complex_set_identity (tmp_mat);
	/*tmp_mat = I - T */
	gsl_matrix_complex_sub (tmp_mat, T);
	/*LU decomposition*/
	gsl_linalg_complex_LU_decomp(tmp_mat, perm, &s);
	/*calculate product G * W = (I - T)^(-1) W directly using LU decomposition*/
	gsl_linalg_complex_LU_solve (tmp_mat, perm, W, tmp_vec);
	/*calculate F.(G * W)*/
	gsl_blas_zdotu (F, tmp_vec, &Jns);

	/*Find Js = F.(G^2 * (I - T^N) * W)  however, this term should be negligible*/

	/*result = N *(2 * Jns + J0) - Js */
	alpha = gsl_complex_mul_real (Jns, 2.0 * avFactor);
	alpha = gsl_complex_add (alpha, J0);

	return m_N * m_I0 * GSL_REAL(alpha) * getPLGfactor(getTheta(Q)) + m_Ibg;
}
示例#12
0
 double Circular::computeTopWidth(double y)
 {
     double theta = getTheta(y);
     return diameter * sin(theta / 2.0);
 }
示例#13
0
 double Circular::computeWettedPerimiter(double y)
 {
     double theta = getTheta(y);
     return 0.5 * theta * diameter;
 }
示例#14
0
    double Circular::computeArea(double y)
    {
        double theta = getTheta(y);
	    return diameter * diameter / 8.0 * (theta - sin(theta));
    }
/* ______________アウトコース走行区間検出_______________________ */
void setSection_out(){
	
/* アウトコース走行区間 */


	static int wait_count = 0;
	wait_count++;

	float def_x  =  getXCoo() - buf_x;
	float def_y  =  getYCoo() - buf_y;
	float def_l  = getDistance() - buf_l;
	float def_th = getTheta( ) - buf_th;

	switch(crt_sect){
	case (START):			//スタート→坂道
		if(getInitGyroOffset() - 30 > (U32)ecrobot_get_gyro_sensor(NXT_PORT_S1) && wait_count > 500){
			ecrobot_sound_tone(220, 100, 50);
			changeSection(&buf_x, &buf_y, &buf_l, &buf_th);
			crt_sect = UP_SLOPE;
			trgt_speed = trgt_speed;
		}
		trgt_R = 0.0;
		break;
	case (UP_SLOPE):		//坂道始点→頂点
		if(def_l >= 30 && getInitGyroOffset() - 30 > (U32)ecrobot_get_gyro_sensor(NXT_PORT_S1)){
			ecrobot_sound_tone(233, 100, 50);
			changeSection(&buf_x, &buf_y, &buf_l, &buf_th);
			crt_sect = DOWN_SLOPE;
			trgt_speed = trgt_speed -10;
		}
		trgt_R = 0.0;
		break;
	case (DOWN_SLOPE):		//頂点→坂道終点
		//if(getDistance() >= 390){
		if(def_l >= 90){
			ecrobot_sound_tone(246, 100, 50);
			changeSection(&buf_x, &buf_y, &buf_l, &buf_th);
			crt_sect = FST_CORNER;
			trgt_speed = trgt_speed - 10;
		}
		trgt_R = 0.0;
		break;
	case (FST_CORNER):		//坂道終点→第一カーブ
		if(def_x >= 74 && def_y >= 70 && def_l >= 110 && def_th >= 90){
			ecrobot_sound_tone(261, 100, 50);
			changeSection(&buf_x, &buf_y, &buf_l, &buf_th);
			crt_sect = FST_STRAIGHT;
			trgt_speed = trgt_speed +20;
		}
		
		trgt_R = 67.59;
		break;
	case (FST_STRAIGHT):	//第一カーブ終点→第一ストレート
		if(def_l >= 115){
			ecrobot_sound_tone(277, 100, 50);
			changeSection(&buf_x, &buf_y, &buf_l, &buf_th);
			crt_sect = SND_CORNER;
			trgt_speed = trgt_speed +10;
		}
		trgt_R = 0.0;
		break;
	case (SND_CORNER):		//第一ストレート終点→第二カーブ
		if(def_x <= -95 && def_y <= -5 && def_l >= 245 && def_th >= 240){
			ecrobot_sound_tone(293, 100, 50);
			changeSection(&buf_x, &buf_y, &buf_l, &buf_th);
			crt_sect = SND_STRAIGHT;
			trgt_speed = trgt_speed;
		}
		trgt_R = 56.59;
		break;
	case (SND_STRAIGHT):	//第二カーブ終点→第二ストレート
		if(def_x >= 40 && def_y <= -15 && def_l >= 40){
			ecrobot_sound_tone(311, 100, 50);
			changeSection(&buf_x, &buf_y, &buf_l, &buf_th);
			crt_sect = TRD_CORNER;
			trgt_speed = trgt_speed;
		}
		trgt_R = 0.0;
		break;
	case (TRD_CORNER):		//第二ストレート終点→第三カーブ
		if(def_x <= -80 && def_y <= -80 && def_l >= 235 && def_th <= -210){
			ecrobot_sound_tone(329, 100, 50);
			changeSection(&buf_x, &buf_y, &buf_l, &buf_th);
			crt_sect = TRD_STRAIGHT;
			trgt_speed = trgt_speed;
		}
		trgt_R = -64.02;
		break;
	case (TRD_STRAIGHT):	//第三カーブ終点→第三ストレート
		if(def_x <= -50 && def_y >= 105 && def_l >= 115){
			ecrobot_sound_tone(349, 100, 50);
			changeSection(&buf_x, &buf_y, &buf_l, &buf_th);
			crt_sect = FIN_APPROACH;
			trgt_speed = trgt_speed;
		}
		trgt_R = 0.0;
		break;
	case (FIN_APPROACH):	//第三ストレート終点→マーカー
		if(1){
			ecrobot_sound_tone(369, 100, 50);
			trgt_speed = trgt_speed;
		}
		trgt_R = 51.80;
		break;
	case (STEPS):			//階段
		if(1){
			ecrobot_sound_tone(369, 100, 50);
		}
		trgt_R = 51.80;
		break;
	case (TURN90D):
		if(1){
			ecrobot_sound_tone(369, 100, 50);
		}
		trgt_R = 51.80;
		break;
	default:
		trgt_speed = 0;
		trgt_R = 0.0;
		break;
	}
}
double QFFCSMaxEntEvaluationItem::getDLSQ() const
{
    return 4.0*M_PI*getRefIndx()/(getLambda()/1e3)*sin(getTheta()/180.0*M_PI/2.0);
}
double QFFCSMaxEntEvaluationItem::getDLSQ(QFRawDataRecord *r, int index, int model) const
{
    return 4.0*M_PI*getRefIndx(r, index, model)/(getLambda(r, index, model)/1e3)*sin(getTheta(r, index, model)/180.0*M_PI/2.0);
}
Bool_t DSelector_checkKFit::Process(Long64_t locEntry)
{
	// The Process() function is called for each entry in the tree. The entry argument
	// specifies which entry in the currently loaded tree is to be processed.
	//
	// This function should contain the "body" of the analysis. It can contain
	// simple or elaborate selection criteria, run algorithms on the data
	// of the event and typically fill histograms.
	//
	// The processing can be stopped by calling Abort().
	// Use fStatus to set the return value of TTree::Process().
	// The return value is currently not used.

	//CALL THIS FIRST
	DSelector::Process(locEntry); //Gets the data from the tree for the entry
	//cout << "RUN " << Get_RunNumber() << ", EVENT " << Get_EventNumber() << endl;
	//TLorentzVector locProductionX4 = Get_X4_Production();

	/******************************************** GET POLARIZATION ORIENTATION ******************************************/

	//Only if the run number changes
	//RCDB environment must be setup in order for this to work! (Will return false otherwise)
	UInt_t locRunNumber = Get_RunNumber();
	if(locRunNumber != dPreviousRunNumber)
	{
		dIsPolarizedFlag = dAnalysisUtilities.Get_IsPolarizedBeam(locRunNumber, dIsPARAFlag);
		dPreviousRunNumber = locRunNumber;
	}

	/********************************************* SETUP UNIQUENESS TRACKING ********************************************/

	//ANALYSIS ACTIONS: Reset uniqueness tracking for each action
	//For any actions that you are executing manually, be sure to call Reset_NewEvent() on them here
	Reset_Actions_NewEvent();

	//PREVENT-DOUBLE COUNTING WHEN HISTOGRAMMING
		//Sometimes, some content is the exact same between one combo and the next
			//e.g. maybe two combos have different beam particles, but the same data for the final-state
		//When histogramming, you don't want to double-count when this happens: artificially inflates your signal (or background)
		//So, for each quantity you histogram, keep track of what particles you used (for a given combo)
		//Then for each combo, just compare to what you used before, and make sure it's unique

	//EXAMPLE 1: Particle-specific info:
	set<Int_t> locUsedSoFar_BeamEnergy; //Int_t: Unique ID for beam particles. set: easy to use, fast to search

	//EXAMPLE 2: Combo-specific info:
		//In general: Could have multiple particles with the same PID: Use a set of Int_t's
		//In general: Multiple PIDs, so multiple sets: Contain within a map
		//Multiple combos: Contain maps within a set (easier, faster to search)
	set<map<Particle_t, set<Int_t> > > locUsedSoFar_Topology;
	bool usedTopology = false;

	//INSERT USER ANALYSIS UNIQUENESS TRACKING HERE

	/**************************************** EXAMPLE: FILL CUSTOM OUTPUT BRANCHES **************************************/
    
	/*
	Int_t locMyInt = 7;
	dTreeInterface->Fill_Fundamental<Int_t>("my_int", locMyInt);

	TLorentzVector locMyP4(4.0, 3.0, 2.0, 1.0);
	dTreeInterface->Fill_TObject<TLorentzVector>("my_p4", locMyP4);

	for(int loc_i = 0; loc_i < locMyInt; ++loc_i)
		dTreeInterface->Fill_Fundamental<Int_t>("my_int_array", 3*loc_i, loc_i); //2nd argument = value, 3rd = array index
	*/

	/************************************************* LOOP OVER COMBOS *************************************************/

	//Loop over combos
	for(UInt_t loc_i = 0; loc_i < Get_NumCombos(); ++loc_i)
	{
		//Set branch array indices for combo and all combo particles
		dComboWrapper->Set_ComboIndex(loc_i);
		
		// Is used to indicate when combos have been cut
		if(dComboWrapper->Get_IsComboCut()) // Is false when tree originally created
			continue; // Combo has been cut previously

		/********************************************** GET PARTICLE INDICES *********************************************/

		//Used for tracking uniqueness when filling histograms, and for determining unused particles

		//Step 0
		Int_t locBeamID = dComboBeamWrapper->Get_BeamID();
		Int_t locPiPlusTrackID = dPiPlusWrapper->Get_TrackID();
		Int_t locPiMinusTrackID = dPiMinusWrapper->Get_TrackID();
		Int_t locProtonTrackID = dProtonWrapper->Get_TrackID();

		/*********************************************** GET FOUR-MOMENTUM **********************************************/

		// Get P4's: //is kinfit if kinfit performed, else is measured
		//dTargetP4 is target p4
		//Step 0
		TLorentzVector locBeamP4 = dComboBeamWrapper->Get_P4();
		TLorentzVector locPiPlusP4 = dPiPlusWrapper->Get_P4();
		TLorentzVector locPiMinusP4 = dPiMinusWrapper->Get_P4();
		TLorentzVector locProtonP4 = dProtonWrapper->Get_P4();

		// Get Measured P4's:
		//Step 0
		TLorentzVector locBeamP4_Measured = dComboBeamWrapper->Get_P4_Measured();
		TLorentzVector locPiPlusP4_Measured = dPiPlusWrapper->Get_P4_Measured();
		TLorentzVector locPiMinusP4_Measured = dPiMinusWrapper->Get_P4_Measured();
		TLorentzVector locProtonP4_Measured = dProtonWrapper->Get_P4_Measured();
		
		//chi2PiPlus = dPiPlusWrapper->Get_Beta_Timing_Measured();
		//chi2Prot = dProtonWrapper->Get_Beta_Timing_Measured();
		
		inVector = locBeamP4_Measured + dTargetP4;
		outVector = locPiPlusP4_Measured + locPiMinusP4_Measured + locProtonP4_Measured;
		
		missingP = (inVector - outVector).P();
		missingE = (inVector - outVector).E();
		mimass_all = (inVector - outVector).M2();
		
		mimassVec = inVector - locProtonP4_Measured;
		imassVec = locPiPlusP4_Measured + locPiMinusP4_Measured;
		
		mimassPipPimVec = inVector - locPiPlusP4_Measured - locPiMinusP4_Measured;
	    mimassPipPim = mimassPipPimVec.M2();
		mimassPipPVec = inVector - locPiPlusP4_Measured - locProtonP4_Measured;
		mimassPipP = mimassPipPVec.M2();
		mimassPimPVec = inVector - locPiMinusP4_Measured - locProtonP4_Measured;
		mimassPimP = mimassPimPVec.M2();
		
		mimass = mimassVec.M();
		imass = imassVec.M();
		
		kfitProb = TMath::Prob(dComboWrapper->Get_ChiSq_KinFit(),dComboWrapper->Get_NDF_KinFit());
		
		pullCollection[0][0] = dComboWrapper->Get_Fundamental<Double_t>("PiPlus__Px_Pull");
		pullCollection[0][1] = dComboWrapper->Get_Fundamental<Double_t>("PiPlus__Py_Pull");
		pullCollection[0][2] = dComboWrapper->Get_Fundamental<Double_t>("PiPlus__Pz_Pull");
		pullCollection[0][3] = dComboWrapper->Get_Fundamental<Double_t>("PiPlus__Vx_Pull");
		pullCollection[0][4] = dComboWrapper->Get_Fundamental<Double_t>("PiPlus__Vy_Pull");
		pullCollection[0][5] = dComboWrapper->Get_Fundamental<Double_t>("PiPlus__Vz_Pull");
		
		pullCollection[1][0] = dComboWrapper->Get_Fundamental<Double_t>("PiMinus__Px_Pull");
		pullCollection[1][1] = dComboWrapper->Get_Fundamental<Double_t>("PiMinus__Py_Pull");
		pullCollection[1][2] = dComboWrapper->Get_Fundamental<Double_t>("PiMinus__Pz_Pull");
		pullCollection[1][3] = dComboWrapper->Get_Fundamental<Double_t>("PiMinus__Vx_Pull");
		pullCollection[1][4] = dComboWrapper->Get_Fundamental<Double_t>("PiMinus__Vy_Pull");
		pullCollection[1][5] = dComboWrapper->Get_Fundamental<Double_t>("PiMinus__Vz_Pull");
		
		pullCollection[2][0] = dComboWrapper->Get_Fundamental<Double_t>("Proton__Px_Pull");
		pullCollection[2][1] = dComboWrapper->Get_Fundamental<Double_t>("Proton__Py_Pull");
		pullCollection[2][2] = dComboWrapper->Get_Fundamental<Double_t>("Proton__Pz_Pull");
		pullCollection[2][3] = dComboWrapper->Get_Fundamental<Double_t>("Proton__Vx_Pull");
		pullCollection[2][4] = dComboWrapper->Get_Fundamental<Double_t>("Proton__Vy_Pull");
		pullCollection[2][5] = dComboWrapper->Get_Fundamental<Double_t>("Proton__Vz_Pull");
		
		//setPullElements(0,0,pullCollection[0][0]);

		/********************************************* COMBINE FOUR-MOMENTUM ********************************************/

		// DO YOUR STUFF HERE

		// Combine 4-vectors
		TLorentzVector locMissingP4_Measured = locBeamP4_Measured + dTargetP4;
		locMissingP4_Measured -= locPiPlusP4_Measured + locPiMinusP4_Measured + locProtonP4_Measured;

		/******************************************** EXECUTE ANALYSIS ACTIONS *******************************************/

		// Loop through the analysis actions, executing them in order for the active particle combo
		if(!Execute_Actions()) //if the active combo fails a cut, IsComboCutFlag automatically set
			continue;

		//if you manually execute any actions, and it fails a cut, be sure to call:
			//dComboWrapper->Set_IsComboCut(true);

		/**************************************** EXAMPLE: FILL CUSTOM OUTPUT BRANCHES **************************************/

		/*
		TLorentzVector locMyComboP4(8.0, 7.0, 6.0, 5.0);
		//for arrays below: 2nd argument is value, 3rd is array index
		//NOTE: By filling here, AFTER the cuts above, some indices won't be updated (and will be whatever they were from the last event)
			//So, when you draw the branch, be sure to cut on "IsComboCut" to avoid these.
		dTreeInterface->Fill_Fundamental<Float_t>("my_combo_array", -2*loc_i, loc_i);
		dTreeInterface->Fill_TObject<TLorentzVector>("my_p4_array", locMyComboP4, loc_i);
		*/

		/**************************************** EXAMPLE: HISTOGRAM BEAM ENERGY *****************************************/

		//Histogram beam energy (if haven't already)
		if(locUsedSoFar_BeamEnergy.find(locBeamID) == locUsedSoFar_BeamEnergy.end())
		{
			locUsedSoFar_BeamEnergy.insert(locBeamID);
		}

		/************************************ EXAMPLE: HISTOGRAM MISSING MASS SQUARED ************************************/

		//Missing Mass Squared
		double locMissingMassSquared = locMissingP4_Measured.M2();

		//Uniqueness tracking: Build the map of particles used for the missing mass
			//For beam: Don't want to group with final-state photons. Instead use "Unknown" PID (not ideal, but it's easy).
		map<Particle_t, set<Int_t> > locUsedThisCombo_Topology;
		locUsedThisCombo_Topology[Unknown].insert(locBeamID); //beam
		locUsedThisCombo_Topology[PiPlus].insert(locPiPlusTrackID);
		locUsedThisCombo_Topology[PiMinus].insert(locPiMinusTrackID);
		locUsedThisCombo_Topology[Proton].insert(locProtonTrackID);
		
		if(locUsedSoFar_Topology.find(locUsedThisCombo_Topology) == locUsedSoFar_Topology.end())
		{
			//unique missing mass combo: histogram it, and register this combo of particles
			//dHist_MissingMassSquared->Fill(locMissingMassSquared);
			
			locUsedSoFar_Topology.insert(locUsedThisCombo_Topology);
			usedTopology = true;
		}else usedTopology = false;
		
        if(usedTopology){
		    missingP_vs_missingE->Fill(missingE,missingP);
		    EM_balance->Fill(missingP-TMath::Abs(missingE));
		    MMALL->Fill(mimass_all);
            MM_vs_IM->Fill(imass,mimass);
            probDist->Fill(kfitProb);
            
            //-----------------------------------------------------------------------------
            if(isInsideDM(missingP-TMath::Abs(missingE),0.0016,0.0106,2)){ //1st cut to reconstruct: gp->pi+pi- p: missing energy and  missing momentum
				probDistCut->Fill(kfitProb);
				missingP_vs_missingE_Cut->Fill(missingE,missingP);
				MM_vs_IM_Cut->Fill(imass,mimass);
				EM_balance_Cut->Fill(missingP-TMath::Abs(missingE));
				MMALL_Cut->Fill(mimass_all);
				
				//-----------------------------------------------------------------------------
				if(mimass_all > -0.005 && mimass_all < 0.005){ //2nd cut to reconstruct: gp->pi+pi- p: overall missing mass --> should be 0
					probDistCut2->Fill(kfitProb);
				    missingP_vs_missingE_Cut2->Fill(missingE,missingP);
				    MM_vs_IM_Cut2->Fill(imass,mimass);
				    EM_balance_Cut2->Fill(missingP-TMath::Abs(missingE));
				    MMALL_Cut2->Fill(mimass_all);	
				     
				     
				     //Angular INDEPENDENT investigation of pulls:
				     //------------------------------------------------------------
		             for(Int_t a=0;a<3;a++){
				        for(Int_t b=0;b<6;b++){
					       Pulls_vs_Prob[a][b]->Fill(kfitProb,pullCollection[a][b]); 
				        }
			         }
			         //------------------------------------------------------------ 
				     
				     
				    fillAngularHists(locPiPlusP4_Measured,locPiMinusP4_Measured,locProtonP4_Measured,Theta_vs_phi_PiPlus,Theta_vs_phi_PiMinus,Theta_vs_phi_Prot);
				       
			         //Angular DEPENDENT investigation of pulls:
				    fillPullHistsPiPlus(getTheta(locPiPlusP4,"deg"),getPhi(locPiPlusP4,"deg"),kfitProb);
				    fillPullHistsPiMinus(getTheta(locPiMinusP4,"deg"),getPhi(locPiMinusP4,"deg"),kfitProb);
				    fillPullHistsProt(getTheta(locProtonP4,"deg"),getPhi(locProtonP4,"deg"),kfitProb);
				}
				//-----------------------------------------------------------------------------
			}
            //-----------------------------------------------------------------------------
		}
    


		//E.g. Cut
		//if((locMissingMassSquared < -0.04) || (locMissingMassSquared > 0.04))
		//{
		//	dComboWrapper->Set_IsComboCut(true);
		//	continue;
		//}

		/****************************************** FILL FLAT TREE (IF DESIRED) ******************************************/

		/*
		//FILL ANY CUSTOM BRANCHES FIRST!!
		Int_t locMyInt_Flat = 7;
		dFlatTreeInterface->Fill_Fundamental<Int_t>("flat_my_int", locMyInt_Flat);

		TLorentzVector locMyP4_Flat(4.0, 3.0, 2.0, 1.0);
		dFlatTreeInterface->Fill_TObject<TLorentzVector>("flat_my_p4", locMyP4_Flat);

		for(int loc_j = 0; loc_j < locMyInt_Flat; ++loc_j)
		{
			dFlatTreeInterface->Fill_Fundamental<Int_t>("flat_my_int_array", 3*loc_j, loc_j); //2nd argument = value, 3rd = array index
			TLorentzVector locMyComboP4_Flat(8.0, 7.0, 6.0, 5.0);
			dFlatTreeInterface->Fill_TObject<TLorentzVector>("flat_my_p4_array", locMyComboP4_Flat, loc_j);
		}
		*/

		//FILL FLAT TREE
		//Fill_FlatTree(); //for the active combo
	} // end of combo loop

	//FILL HISTOGRAMS: Num combos / events surviving actions
	Fill_NumCombosSurvivedHists();

	/******************************************* LOOP OVER THROWN DATA (OPTIONAL) ***************************************/
/*
	//Thrown beam: just use directly
	if(dThrownBeam != NULL)
		double locEnergy = dThrownBeam->Get_P4().E();

	//Loop over throwns
	for(UInt_t loc_i = 0; loc_i < Get_NumThrown(); ++loc_i)
	{
		//Set branch array indices corresponding to this particle
		dThrownWrapper->Set_ArrayIndex(loc_i);

		//Do stuff with the wrapper here ...
	}
*/
	/****************************************** LOOP OVER OTHER ARRAYS (OPTIONAL) ***************************************/
/*
	//Loop over beam particles (note, only those appearing in combos are present)
	for(UInt_t loc_i = 0; loc_i < Get_NumBeam(); ++loc_i)
	{
		//Set branch array indices corresponding to this particle
		dBeamWrapper->Set_ArrayIndex(loc_i);

		//Do stuff with the wrapper here ...
	}

	//Loop over charged track hypotheses
	for(UInt_t loc_i = 0; loc_i < Get_NumChargedHypos(); ++loc_i)
	{
		//Set branch array indices corresponding to this particle
		dChargedHypoWrapper->Set_ArrayIndex(loc_i);

		//Do stuff with the wrapper here ...
	}

	//Loop over neutral particle hypotheses
	for(UInt_t loc_i = 0; loc_i < Get_NumNeutralHypos(); ++loc_i)
	{
		//Set branch array indices corresponding to this particle
		dNeutralHypoWrapper->Set_ArrayIndex(loc_i);

		//Do stuff with the wrapper here ...
	}
*/

	/************************************ EXAMPLE: FILL CLONE OF TTREE HERE WITH CUTS APPLIED ************************************/
/*
	Bool_t locIsEventCut = true;
	for(UInt_t loc_i = 0; loc_i < Get_NumCombos(); ++loc_i) {
		//Set branch array indices for combo and all combo particles
		dComboWrapper->Set_ComboIndex(loc_i);
		// Is used to indicate when combos have been cut
		if(dComboWrapper->Get_IsComboCut())
			continue;
		locIsEventCut = false; // At least one combo succeeded
		break;
	}
	if(!locIsEventCut && dOutputTreeFileName != "")
		Fill_OutputTree();
*/

	return kTRUE;
}
示例#19
0
void Arma::atirar(float theta, float time){
  setX(cos(getTheta()*M_PI/180 )*time);
  setY(sin(getTheta()*M_PI/180 )*time);
}
void changeSection(float *buf_x, float *buf_y, float *buf_l, float *buf_th){
	*buf_x =  getXCoo();	*buf_y =  getYCoo();
	*buf_l = getDistance();	*buf_th = getTheta( );
}