const ElectronPointer QCDPFRelIsoEPlusJetsSelection::MostIsolatedElectron(const ElectronCollection& electrons) const {
	double bestIsolation = 999999999;
	unsigned int bestIsolatedLepton = 990;

	for (unsigned int index = 0; index < electrons.size(); ++index) {
		double currentIsolation(electrons.at(index)->pfRelativeIsolationRhoCorrected());

		if (currentIsolation < bestIsolation) {
			bestIsolation = currentIsolation;
			bestIsolatedLepton = index;
		}
	}
	ElectronPointer electron(new Electron());

	if (bestIsolatedLepton < electrons.size())
		electron = electrons.at(bestIsolatedLepton);

	return electron;
}
void ElectronReader::readElectrons() {

	for (unsigned int index = 0; index < energyReader.size(); index++) {
		double energy = energyReader.getVariableAt(index);
		double px = pxReader.getVariableAt(index);
		double py = pyReader.getVariableAt(index);
		double pz = pzReader.getVariableAt(index);
		ElectronPointer electron(new Electron(energy, px, py, pz));
		electron->setUsedAlgorithm(algorithm);
		electron->setCharge(chargeReader.getIntVariableAt(index));
		if (d0_BS_Reader.doesVariableExist() && algorithm == ElectronAlgorithm::Calo)
			electron->setD0_wrtBeamSpot(d0_BS_Reader.getVariableAt(index));
		electron->setD0(d0_PV_Reader.getVariableAt(index));
		electron->setZDistanceToPrimaryVertex(vertex_dist_z.getVariableAt(index));
		electron->setNumberOfMissingInnerLayerHits(numberOfInnerLayerMissingHitsReader.getIntVariableAt(index));

		electron->setEcalIsolation(ecalIsolationReader_DR03_.getVariableAt(index), 0.3);
		electron->setHcalIsolation(hcalIsolationReader_DR03_.getVariableAt(index), 0.3);
		electron->setTrackerIsolation(trackerIsolationReader_DR03_.getVariableAt(index), 0.3);
		electron->setEcalIsolation(ecalIsolationReader_DR04_.getVariableAt(index), 0.4);
		electron->setHcalIsolation(hcalIsolationReader_DR04_.getVariableAt(index), 0.4);
		electron->setTrackerIsolation(trackerIsolationReader_DR04_.getVariableAt(index), 0.4);

		electron->setSuperClusterEta(superClusterEtaReader.getVariableAt(index));
		electron->setSigmaIEtaIEta(sigmaIEtaIEtaReader.getVariableAt(index));
		electron->setDPhiIn(dPhiInReader.getVariableAt(index));
		electron->setDEtaIn(dEtaInReader.getVariableAt(index));
		electron->setHadOverEm(hadOverEmReader.getVariableAt(index));
		electron->setDistToNextTrack(dist.getVariableAt(index));
		electron->setDCotThetaToNextTrack(dCotTheta.getVariableAt(index));

		if (algorithm == ElectronAlgorithm::ParticleFlow) {
			electron->setPFGammaIsolation(PFGammaIsolationReader_DR03_.getVariableAt(index), 0.3);
			electron->setPFChargedHadronIsolation(PFChargedHadronIsolationReader_DR03_.getVariableAt(index), 0.3);
			electron->setPFNeutralHadronIsolation(PFNeutralHadronIsolationReader_DR03_.getVariableAt(index), 0.3);
			electron->setPFGammaIsolation(PFGammaIsolationReader_DR04_.getVariableAt(index), 0.4);
			electron->setPFChargedHadronIsolation(PFChargedHadronIsolationReader_DR04_.getVariableAt(index), 0.4);
			electron->setPFNeutralHadronIsolation(PFNeutralHadronIsolationReader_DR04_.getVariableAt(index), 0.4);
			electron->setPFGammaIsolation(PFGammaIsolationReader_DR05_.getVariableAt(index), 0.5);
			electron->setPFChargedHadronIsolation(PFChargedHadronIsolationReader_DR05_.getVariableAt(index), 0.5);
			electron->setPFNeutralHadronIsolation(PFNeutralHadronIsolationReader_DR05_.getVariableAt(index), 0.5);
			if (Globals::NTupleVersion >= 6) {
				electron->setDirectionalIsolation(DirectionalIsolationReader_DR02_.getVariableAt(index), 0.2);
				electron->setDirectionalIsolation(DirectionalIsolationReader_DR03_.getVariableAt(index), 0.3);
				electron->setDirectionalIsolationWithGaussianFallOff(
						DirectionalIsolationReaderWithGaussianFallOff_DR02_.getVariableAt(index), 0.2);
				electron->setDirectionalIsolationWithGaussianFallOff(
						DirectionalIsolationReaderWithGaussianFallOff_DR03_.getVariableAt(index), 0.3);
				electron->setPFIsolationWithGaussianFallOff(
						PFIsolationReaderWithGaussianFallOff_DR02_.getVariableAt(index), 0.2);
				electron->setPFIsolationWithGaussianFallOff(
						PFIsolationReaderWithGaussianFallOff_DR03_.getVariableAt(index), 0.3);
			}

		}
		if (Globals::NTupleVersion >= 7) {
			electron->setMVATrigV0(mvaTrigV0_.getVariableAt(index));
			electron->setMVANonTrigV0(mvaNonTrigV0_.getVariableAt(index));
			electron->setPassConversionVeto(passConversionVeto_.getBoolVariableAt(index));
			electron->setPFPUChargedHadronIsolation(PFPUChargedHadron_Isolation_DR03_.getVariableAt(index), 0.3);
			electron->setPFPUChargedHadronIsolation(PFPUChargedHadron_Isolation_DR04_.getVariableAt(index), 0.4);
			electron->setPFPUChargedHadronIsolation(PFPUChargedHadron_Isolation_DR05_.getVariableAt(index), 0.5);
		} else {
			electron->setMVATrigV0(-1);
			electron->setMVANonTrigV0(-1);
			electron->setPassConversionVeto(false);
			electron->setPFPUChargedHadronIsolation(0, 0.3);
			electron->setPFPUChargedHadronIsolation(0, 0.4);
			electron->setPFPUChargedHadronIsolation(0, 0.5);
		}

		if(Globals::NTupleVersion >= 9){
			electron->setPFRelativeIsolationRho(PFRelativeIsolationRho_DR03_.getVariableAt(index));
		}

		electrons.push_back(electron);
	}
}
Exemplo n.º 3
0
int main()
{
  particle electron(0.511, -1);
  electron.say_hello();
  return 0;
}
Exemplo n.º 4
0
/* draw the user object */
static int  draw_object( int obj_id, double gl_para[16], int collide_flag )
{
    GLfloat   mat_ambient[]				= {0.0, 0.0, 1.0, 1.0};
	GLfloat   mat_ambient_collide[]     = {0.0, 1.0, 0.0, 1.0};
    GLfloat   mat_flash[]				= {0.0, 0.0, 1.0, 1.0};
	GLfloat   mat_flash_collide[]       = {1.0, 0.0, 0.0, 1.0};
    GLfloat   mat_flash_shiny[] = {50.0};
    GLfloat   light_position[]  = {100.0,-200.0,200.0,0.0};
    GLfloat   ambi[]            = {0.0, 0.1, 0.1, 0.1};
    GLfloat   lightZeroColor[]  = {0.9, 0.9, 0.9, 0.1};
 
    argDrawMode3D();
    argDraw3dCamera( 0, 0 );
    glMatrixMode(GL_MODELVIEW);
    glLoadMatrixd( gl_para );

 	/* set the material */
    glEnable(GL_LIGHTING);
    glEnable(GL_LIGHT0);
    glLightfv(GL_LIGHT0, GL_POSITION, light_position);
    glLightfv(GL_LIGHT0, GL_AMBIENT, ambi);
    glLightfv(GL_LIGHT0, GL_DIFFUSE, lightZeroColor);

    glMaterialfv(GL_FRONT, GL_SHININESS, mat_flash_shiny);	

	if(collide_flag){
		printf("its collided");
		if (obj_id == 0)
		{
			glMaterialfv(GL_FRONT, GL_SPECULAR, mat_flash);
			glMaterialfv(GL_FRONT, GL_AMBIENT, mat_ambient);
			/* draw a cube */
			//glTranslatef( 0.0, 0.0, 30.0 );
			//glutSolidSphere(30,12,6);
			electron3();
			
		}
		
	}
	else {
		printf("its not");
		if (obj_id == 0)
		{
			renderBitmapString(0, 0, 0, GLUT_BITMAP_HELVETICA_18, "HYDROGEN");
			glMaterialfv(GL_FRONT, GL_SPECULAR, mat_flash);
			glMaterialfv(GL_FRONT, GL_AMBIENT, mat_ambient);
			/* draw a cube */
			//glTranslatef( 0.0, 0.0, 30.0 );
			//glutSolidSphere(30,12,6);
			glTranslatef(-50.0, -50.0, 0.0);
			glScaled(2, 2, 2);
			electron2();
		}
		else if (obj_id == 1)
		{
			glPushMatrix();
			
			renderBitmapString(0, 0, 0, GLUT_BITMAP_HELVETICA_18, "OXYGEN");
			glPopMatrix();
			glMaterialfv(GL_FRONT, GL_SPECULAR, mat_flash);
			glMaterialfv(GL_FRONT, GL_AMBIENT, mat_ambient);
		
			glTranslatef(0.0, 0.0, 0.0);
			glScaled(3, 3, 3);
			electron();
		}
	}

    argDrawMode2D();

    return 0;

}
Exemplo n.º 5
0
void init_physics()
{
	ions[0] = proton();
	ions[1] = electron();
	ions[0].location = (struct vector) {0,0,0};
	ions[0].velocity=(struct vector){0,0,0};
	ions[1].location = (struct vector) {0,20,0};
	ions[1].velocity=(struct vector){0.15,0,0};
}

/*
void init_physics()
{
#define RANDO ((rand()%100)-50)
	int i;
	for(i=0;i<N_IONS;i++){
		switch(rand()%8){
			case 0:
				ions[i] = nuclion(rand()%9);
				break;
			default:
				ions[i] = electron();
				break;
		}
		ions[i].location = (struct vector) {RANDO,RANDO,RANDO};
		ions[i].velocity=(struct vector){0,0,0};
	}
}
*/

void dump_state()
{
	int i;
	printf("--- IONS ---\n");
	for(i=0;i<N_IONS;i++){
		printf("[%i]\n",i);
		printf("charge %Lf \n",ions[i].charge);
		printf("mass %Lf \n",ions[i].mass);
		v_print("location",ions[i].location);
		v_printe("velocity",ions[i].velocity);
		v_printe("acceleration",ions[i].accel);
	}
	printf("-----------\n");
}

void calculate_acceleration(struct particle * p,double dt)
{
	struct vector fv = {0,0,0};
	int i;
	for(i=0;i<N_IONS;i++){
		fv = v_add(fv,gravitation(ions[i],*p));
		fv = v_add(fv,coulombs(ions[i],*p));
//		fv = v_add(fv,biotsavart(ions[i],*p));
	}
	/* because f/m=a */
	fv.x/=p->mass;
	fv.y/=p->mass;
	fv.z/=p->mass;
	p->accel = v_scalar_mul(dt,fv);
}

void apply_vel(struct particle * p)
{
	p->velocity = v_add(p->accel,p->velocity);
	p->location = v_add(p->location,p->velocity);
}

void physics_tick(double dt)
{
	int i;
	for(i=0;i<N_IONS;i++)
		calculate_acceleration(&ions[i],dt);
	for(i=0;i<N_IONS;i++)
		apply_vel(&ions[i]);
	if(keys['P'])
		dump_state();
}