Ejemplo n.º 1
0
//---------------------------------------------------------------------------//
// Draw
//
//---------------------------------------------------------------------------//
void CFilterScanner::Draw(CDisplayDevice *pDD, TRenderTgt *pRenderTgt, float fAlphaGlobal)
{
  D3DDEVICE *pD3D = pDD->GetD3DDevice();
  int iTex = CEffects::GetTexture(CEffects::TEX_TARGET);
  pDD->SetRenderTarget(iTex);

  // Render el fondo y la capa de scanner
  pDD->ApplyBasicShader();
  g_pGestorMateriales->SetTextura(pRenderTgt->iTexture, 0);
  DrawQuad(pDD);

  TVector2 v0,   v1;
  TVector2 uv0, uv1;
  CalcScannerRect(TVector2(100,100), TVector2(420,340), 0.7f, &v0, &v1);
  uv0 = TVector2(100.f/pDD->Width(), 100.f/pDD->Height());
  uv1 = TVector2(420.f/pDD->Width(), 340.f/pDD->Height());
  DrawQuadUV(pDD, v0, v1, uv0, uv1);

  // Dibujar con el filtro y el modo seleccionados
  pDD->SetRenderTarget(-1);
  pDD->ApplyBasicShader();
  g_pGestorMateriales->SetTextura(iTex, 0);
  ApplyMode(pDD, pRenderTgt, fAlphaGlobal);
  pD3D->SetTextureStageState(0, D3DTSS_ALPHAOP,   D3DTOP_SELECTARG1);
  pD3D->SetTextureStageState(0, D3DTSS_ALPHAARG1, D3DTA_TFACTOR);
  pDD->SetBilinearFiltering(0, true);

  DrawQuad(pDD);
}
Ejemplo n.º 2
0
//---------------------------------------------------------------------------//
// Draw
//
//---------------------------------------------------------------------------//
void CFXAviVideo::Draw(CDisplayDevice *pDD)
{
  pDD->SetRenderTarget(m_RenderTarget.iTexture);
  
  D3DDEVICE *pD3D = pDD->GetD3DDevice();

  // Frame actual
  m_iFrame = m_pAvi->TimeToFrame(fmodf(m_fTime, GetLength()) + m_fStart*m_fLength);
  if (m_iFrame != m_iCachedFrame)
  {
    CTextura *pTextura = g_pGestorMateriales->GetTextura(m_iTextura);
    if (!m_pAvi->GetFrame(m_iFrame, pTextura))
      return;
    m_iCachedFrame = m_iFrame;
  }
  
  // Quad con textura
  g_pGestorMateriales->SetTextura(m_iTextura, 0);

  // RenderStates especificos
  pDD->ApplyBasicShader();
  pD3D->SetRenderState(D3DRS_CLIPPING,         FALSE);
  pD3D->SetRenderState(D3DRS_TEXTUREFACTOR,    m_Color);
  pD3D->SetRenderState(D3DRS_ZWRITEENABLE,     D3DZB_FALSE);  
  pD3D->SetRenderState(D3DRS_ZENABLE,          D3DZB_FALSE);
  pD3D->SetRenderState(D3DRS_BLENDOP,          D3DBLENDOP_ADD);

  pD3D->SetTextureStageState(0, D3DTSS_COLOROP,   D3DTOP_MODULATE);
  pD3D->SetTextureStageState(0, D3DTSS_COLORARG1, D3DTA_TEXTURE  );
  pD3D->SetTextureStageState(0, D3DTSS_COLORARG2, D3DTA_TFACTOR  );

  pD3D->SetTextureStageState(0, D3DTSS_ALPHAOP,   D3DTOP_SELECTARG1);
  pD3D->SetTextureStageState(0, D3DTSS_ALPHAARG1, D3DTA_TFACTOR    );

  pD3D->SetTextureStageState(1, D3DTSS_COLOROP,   D3DTOP_DISABLE);
  pD3D->SetTextureStageState(1, D3DTSS_ALPHAOP,   D3DTOP_DISABLE);

  pD3D->SetSamplerState(0, D3DSAMP_MAGFILTER, D3DTEXF_LINEAR);
  pD3D->SetSamplerState(0, D3DSAMP_MINFILTER, D3DTEXF_LINEAR);

  pD3D->SetVertexShader(NULL);
  pD3D->SetPixelShader (NULL);

  if (m_bInvert)
  {
    pD3D->SetRenderState(D3DRS_ALPHABLENDENABLE, TRUE);
    pD3D->SetRenderState(D3DRS_BLENDOP,   D3DBLENDOP_ADD);
    pD3D->SetRenderState(D3DRS_SRCBLEND,  D3DBLEND_SRCALPHA);
		pD3D->SetRenderState(D3DRS_DESTBLEND, D3DBLEND_INVSRCCOLOR);
  }
  else
  {
    pD3D->SetRenderState(D3DRS_ALPHABLENDENABLE, FALSE);
  }

  DrawQuadUV(pDD, TVector2(m_fCropL, 1.f-m_fCropB), TVector2(m_fCropR, 1.f-m_fCropT), true);
}
Ejemplo n.º 3
0
std::vector<unsigned int> HashTable::FindNN(TVector2 position) {
  std::vector<unsigned int> results;
  std::vector<unsigned int> cell;
  TVector2 min = Discretize(position) - TVector2(_NG_H_,_NG_H_);
  TVector2 max = Discretize(position) + TVector2(_NG_H_,_NG_H_);

  for(TVector2 it(min); it.X() <= max.X() ; it.Set(it.X()+1,it.Y())) {
    for(it.Set(it.X(),min.Y());it.Y() <= max.Y(); it.Set(it.X(),it.Y()+1)) {
      cell.clear();
      cell = hashTable[GetHash(it)];
      results.insert(results.end(), cell.begin(), cell.end());
    }
  }

  return results;
}
Ejemplo n.º 4
0
void break_track_marks() {
	list<track_quad_t>::iterator q = track_marks.current_mark;
	if (q != track_marks.quads.end()) {
		q->track_type = TRACK_TAIL;
		q->t1 = TVector2(0.0, 0.0);
		q->t2 = TVector2(1.0, 0.0);
		q->t3 = TVector2(0.0, 1.0);
		q->t4 = TVector2(1.0, 1.0);
		list<track_quad_t>::iterator qprev = decrementRingIterator(q);
		if (qprev != track_marks.quads.end()) {
			qprev->t3.y = max((int)(qprev->t3.y+0.5), (int)(qprev->t1.y+1));
			qprev->t4.y = max((int)(qprev->t3.y+0.5), (int)(qprev->t1.y+1));
		}
    }
    continuing_track = false;
}
Ejemplo n.º 5
0
//---------------------------------------------------------------------------//
// Init
//
//---------------------------------------------------------------------------//
bool CFXImagen::Init(const string &sFile)
{
  m_bOk     = true;
  m_iImagen = 0;
  m_Nombre  = sFile;

  // Imagenes
  m_Imagen.iIDTex = g_pGestorMateriales->AddTextura(sFile.c_str());
  if (m_Imagen.iIDTex < 0)
    GLOG(("ERR: Can't load image file %s\n", sFile.c_str()));
  m_Imagen.iStretchMode = STRETCH_FILL;
  m_Imagen.vPos   = TVector2(0.f, 0.f);
  m_Imagen.vPosIni= TVector2(0.f, 0.f);
  m_Imagen.vSpeed = TVector2(0.f, 0.f);
  m_Imagen.vXform = TVector2(0.f, 0.f);

  return (IsOk());
}
Ejemplo n.º 6
0
bool CKeyframe::Load (const string& dir, const string& filename) {
	if (loaded && loadedfile == filename) return true;
	CSPList list (1000);

	if (list.Load (dir, filename)) {
		frames.resize(list.Count());
		for (size_t i=0; i<list.Count(); i++) {
			const string& line = list.Line(i);
			frames[i].val[0] = SPFloatN (line, "time", 0);
			TVector3 posit = SPVector3N (line, "pos", NullVec);
			frames[i].val[1] = posit.x;
			frames[i].val[2] = posit.y;
			frames[i].val[3] = posit.z;
			frames[i].val[4] = SPFloatN (line, "yaw", 0);
			frames[i].val[5] = SPFloatN (line, "pitch", 0);
			frames[i].val[6] = SPFloatN (line, "roll", 0);
			frames[i].val[7] = SPFloatN (line, "neck", 0);
			frames[i].val[8] = SPFloatN (line, "head", 0);
			TVector2 pp = SPVector2N (line, "sh", TVector2(0, 0));
			frames[i].val[9] = pp.x;
			frames[i].val[10] = pp.y;
			pp = SPVector2N (line, "arm", TVector2(0, 0));
			frames[i].val[11] = pp.x;
			frames[i].val[12] = pp.y;
			pp = SPVector2N (line, "hip", TVector2(0, 0));
			frames[i].val[13] = pp.x;
			frames[i].val[14] = pp.y;
			pp = SPVector2N (line, "knee", TVector2(0, 0));
			frames[i].val[15] = pp.x;
			frames[i].val[16] = pp.y;
			pp = SPVector2N (line, "ankle", TVector2(0, 0));
			frames[i].val[17] = pp.x;
			frames[i].val[18] = pp.y;
		}
		loaded = true;
		loadedfile = filename;
		return true;
	} else {
		Message ("keyframe not found:", filename);
		loaded = false;
		return false;
	}
}
Ejemplo n.º 7
0
void ExperimentalPoint::LoadMap(){
	TString pos; 
	double X, Y ;
	ifstream file;

	file.open("./input/PositionMap.dat");
	while (file>>pos>>X>>Y){
		//cout << " pos " << pos << "  " << X << " " << Y << endl ; 
		fmapPosition.insert ( std::pair<TString,TVector2>(pos,TVector2(X,Y)));
	}
	//cout << "  finished reading the position map. " << endl ; 
}
Ejemplo n.º 8
0
//---------------------------------------------------------------------------//
// Draw
//
//---------------------------------------------------------------------------//
void CFXImagen::Draw(CDisplayDevice *pDD, int iTextureTgt)
{
  pDD->SetRenderTarget(iTextureTgt);

  // Si la imagen no se cargó bien, salimos
  if (m_Imagen.iIDTex < 0) return;

  CTextura *pTex = g_pGestorMateriales->GetTextura(m_Imagen.iIDTex);
  TVector2  vPos = m_Imagen.vPos;
  TVector2  vSize;

  // Tamaño
  int iW = pDD->ViewportWidth ();
  int iH = pDD->ViewportHeight();
  switch (m_Imagen.iStretchMode)
  {
    case STRETCH_FILL:
      vSize.x = (float)iW;
      vSize.y = (float)iH;
      break;
    case STRETCH_TOW:
      vSize.x = (float)iW;
      vSize.y = (float)iW * pTex->GetHeight() / (float)pTex->GetWidth();
      break;
    case STRETCH_TOH:
      vSize.x = (float)iH * pTex->GetWidth () / (float)pTex->GetHeight();
      vSize.y = (float)iH;
      break;
  }
  
  // Quad con textura
  LPDIRECT3DDEVICE9 pD3D = pDD->GetD3DDevice();
  g_pGestorMateriales->SetTextura(m_Imagen.iIDTex, 0);

  // RenderStates especificos
  pDD->ApplyBasicShader();
  pDD->SetBilinearFiltering(false,false);

  DrawQuad(pDD, TVector2(vPos.x, vPos.y), TVector2(vPos.x+vSize.x, vPos.y+vSize.y));
}
Ejemplo n.º 9
0
//----------------------------------------------------------------------------
// Draw
//
//----------------------------------------------------------------------------
void CVJLoader::Draw(CDisplayDevice *pDD)
{
  pDD->BeginFrame();
  pDD->BeginScene();
  pDD->Clear(true, true, 0, 1.f);
  TVector2 vIni = TVector2((float)pDD->Width() - 126.f, (float)pDD->Height()-12.f);
  TVector2 vEnd = TVector2((float)pDD->Width() -   6.f, (float)pDD->Height()- 6.f);
  float fPos = ((float)m_iPos * (vEnd.x-vIni.x-4.f) / (float)m_iMax) + vIni.x + 2.f;
  DrawQuadFlat(pDD, TVector2(vIni.x+0,vIni.y+0), TVector2(vEnd.x-0,vEnd.y-0), HARD_COLOR_ARGB(255,255,168,  0), 0.f);
  DrawQuadFlat(pDD, TVector2(vIni.x+1,vIni.y+1), TVector2(vEnd.x-1,vEnd.y-1), HARD_COLOR_ARGB(255,  0,  0,  0), 0.f);
  DrawQuadFlat(pDD, TVector2(vIni.x+2,vIni.y+2), TVector2(fPos,    vEnd.y-2), HARD_COLOR_ARGB(255,255,168,  0), 0.f);
  pDD->EndScene();
  pDD->EndFrame();
  pDD->PageFlip();
}
Ejemplo n.º 10
0
//---------------------------------------------------------------------------//
// Draw
//
//---------------------------------------------------------------------------//
void CFXMessage::Draw(CDisplayDevice *pDD)
{
  pDD->SetRenderTarget(m_RenderTarget.iTexture);
  if (m_bFirstClear || m_bClear)
  {
    pDD->Clear(true, true, 0, 1.f);
    m_bFirstClear = false;
  }

  float fW = (float)pDD->ViewportWidth ();
  float fH = (float)pDD->ViewportHeight();

  // Create a rectangle to indicate where on the screen it should be drawn
  RECT rct;
  rct.left  = 30;
  rct.right = (int)fW - 80;
  rct.top   = (int)m_fPosY;
  rct.bottom= rct.top + 80;
  RECT rctSombra = rct;
  rctSombra.left  +=2;
  rctSombra.right +=2;
  rctSombra.top   +=2;
  rctSombra.bottom+=2;
 
  pDD->ApplyBasicShader();
  if (m_iTexFondo != -1)
  {
    D3DDEVICE *pD3D = pDD->GetD3DDevice();
    pD3D->SetTextureStageState(0, D3DTSS_ALPHAOP,   D3DTOP_SELECTARG1);
    pD3D->SetTextureStageState(0, D3DTSS_ALPHAARG1, D3DTA_TEXTURE);
    pDD->SetBilinearFiltering(0, false);
    CTextura *pTex = g_pGestorMateriales->GetTextura(m_iTexFondo);
    g_pGestorMateriales->SetTextura(m_iTexFondo, 0);
    DrawQuadUV(pDD, TVector2(rct.left-10.f, rct.top-5.f), TVector2(rct.right+10.f, rct.bottom+5.f),
                    TVector2(0.0f, 0.0f), TVector2((float)(rct.right - rct.left + 1) / pTex->GetWidth(), (float)(rct.bottom - rct.top + 1) / pTex->GetHeight()));
  }
  else
    DrawQuadFlat(pDD, TVector2(rct.left-10.f, rct.top-5.f), TVector2(rct.right+10.f, rct.bottom+5.f), HARD_COLOR_ARGB(255,255,96,64), 0.f);
  m_pFont->DrawText(NULL, m_pMessage, -1, &rctSombra, DT_WORDBREAK, HARD_COLOR_ARGB(255,0,0,0));
  m_pFont->DrawText(NULL, m_pMessage, -1, &rct, DT_WORDBREAK, HARD_COLOR_ARGB(255,255,255,255));
}
Ejemplo n.º 11
0
// D0 RedMET with CMG trees
double getD0RedMet(double lpx1, double lpy1, double lpterr1, 
		   double lpx2, double lpy2, double lpterr2, 
		   double sumjpx, double sumjpy, 
		   double pfmet, double pfmetphi, 
		   int flav, int pickAFlav = 1) {
			   


  if( flav==3 ) { 
    if( pickAFlav!=1 && pickAFlav!=2 ) {
      cout << " *** ERROR *** " << endl;
      cout << "  You need to pick a flavor in getD0RedMet(...)! " << endl;
      throw std::exception();
      return -1.;
    }
    else {
      flav = pickAFlav;
    }
  }

  // double wPerpMu = 1.0;
  // double wRecMu  = 2.0;
  // double wUncMu  = 2.5;
  double wPerpMu = 1.0;
  double wRecMu  = 1.5;
  double wUncMu  = 2.75;

  // double wPerpEl = 1.5;
  // double wRecEl  = 2.25;
  // double wUncEl  = 0.0;
  double wPerpEl = 0.75;
  double wRecEl  = 1.0;
  double wUncEl  = 0.25;
  
  int seplep = 1;
  
  if (seplep == 0){
		wPerpMu = 1.0;
		wRecMu  = 1.25;
		wUncMu  = 0.0;
		wPerpEl = wPerpMu;
		wRecEl  = wRecMu;
		wUncEl  = wUncMu;
  }

  double kPerp = 1.;
  double kRecoil_l = 1.;
  double kRecoil_t = 1.;
  double kSigmaPt_l = 1.;
  double kSigmaPt_t = 1.;

  if( flav==1 ) {        // mm
    kPerp = wPerpMu;
    kRecoil_l = kRecoil_t = wRecMu;
    kSigmaPt_l = kSigmaPt_t = wUncMu;
  }
  else if( flav==2 ) {  // ee
    kPerp = wPerpEl;
    kRecoil_l = kRecoil_t = wRecEl;
    kSigmaPt_l = kSigmaPt_t = wUncEl;
  }
  else {}

  double pt1 = sqrt(lpx1*lpx1 + lpy1*lpy1);
  double pt2 = sqrt(lpx2*lpx2 + lpy2*lpy2);

  TVector2 lead, subl;
  double leadpt, sublpt, leadpterr, sublpterr;
  if(pt1>pt2) {
    lead = TVector2(lpx1, lpy1);
    subl = TVector2(lpx2, lpy2);
    leadpt = pt1;
    leadpterr = lpterr1;
    sublpt = pt2;
    sublpterr = lpterr2;
  }
  else {
    lead = TVector2(lpx2, lpy2);
    subl = TVector2(lpx1, lpy1);
    leadpt = pt2;
    leadpterr = lpterr2;
    sublpt = pt1;
    sublpterr = lpterr1;
  }

  // Define the thrust and dilepton
  TVector2 dil = lead+subl;
  TVector2 thr = lead-subl;
  TVector2 longi;
  TVector2 perpe;
  double deltaPhi = fabs(lead.DeltaPhi(subl));

  if( deltaPhi>(3.141592654/2.) ) {
    longi = thr.Unit();
    perpe = longi.Rotate(3.141592654/2.);
    if(perpe*lead<0) perpe *= -1;
  }
  else {
    perpe = dil.Unit();
    longi = perpe.Rotate(3.141592654/2.);
    if(longi*lead<0) longi *= -1;
  }

  // Dilepton
  double dileptProj_l = dil*longi;
  double dileptProj_t = dil*perpe;

  // Unclustered
  TVector2 uncl( pfmet*cos(pfmetphi), pfmet*sin(pfmetphi) );
  uncl += dil;
  double unclProj_l = uncl*longi;
  double unclProj_t = uncl*perpe;

  // Sum of jets
  TVector2 sumjVec(sumjpx, sumjpy);
  double sumjetProj_l = sumjVec*longi;
  double sumjetProj_t = sumjVec*perpe;

  // Recoil
  double recoilProj_l = min( sumjetProj_l, -1.0*unclProj_l ); recoilProj_l = min( 0., recoilProj_l );
  double recoilProj_t = min( sumjetProj_t, -1.0*unclProj_t ); recoilProj_t = min( 0., recoilProj_t );
  // Case with 0 jets
  // double recoilProj_l = -1.0*unclProj_l; recoilProj_l = min( 0., recoilProj_l );
  // double recoilProj_t = -1.0*unclProj_t; recoilProj_t = min( 0., recoilProj_t );

  // Lepton uncertainty
  double relErrLead = min( leadpterr/leadpt, 1. );
  double relErrSubl = min( sublpterr/sublpt, 1. );
  TVector2 lowLead = lead*(1.0-relErrLead);
  TVector2 lowSubl = subl*(1.0-relErrSubl);
  TVector2 lowDil = lowLead + lowSubl;
  TVector2 lowThr = lowLead - lowSubl;

  double deltaDileptProj_t = lowDil*perpe - dileptProj_t;
  double deltaDileptProj_l = ( -relErrLead*lead + relErrSubl*subl )*longi;

  double redMET_l = max( (dileptProj_l + kRecoil_l*recoilProj_l + kSigmaPt_l*deltaDileptProj_l), 0.);
  double redMET_t = max( (dileptProj_t + kRecoil_t*recoilProj_t + kSigmaPt_t*deltaDileptProj_t), 0.);
  double redMET = sqrt( pow(redMET_l,2) + kPerp*pow(redMET_t,2) );

  return redMET;
}
Ejemplo n.º 12
0
// --------------------------------------------------------------------
//                      add_track_mark
// --------------------------------------------------------------------
void add_track_mark(const CControl *ctrl, int *id) {
    if (param.perf_level < 3)
		return;

	TTerrType *TerrList = &Course.TerrList[0];

	*id = Course.GetTerrainIdx (ctrl->cpos.x, ctrl->cpos.z, 0.5);
	if (*id < 1) {
		break_track_marks();
		return;
	}

	if (!TerrList[*id].trackmarks) {
		break_track_marks();
		return;
	}

	TVector3 vel = ctrl->cvel;
    double speed = NormVector (vel);
    if (speed < SPEED_TO_START_TRENCH) {
		break_track_marks();
		return;
    }

    TVector3 width_vector = CrossProduct (ctrl->cdirection, TVector3 (0, 1, 0));
    double magnitude = NormVector (width_vector);
    if (magnitude == 0) {
		break_track_marks();
		return;
    }

    TVector3 left_vector = ScaleVector (TRACK_WIDTH/2.0, width_vector);
    TVector3 right_vector = ScaleVector (-TRACK_WIDTH/2.0, width_vector);
    TVector3 left_wing =  SubtractVectors (ctrl->cpos, left_vector);
    TVector3 right_wing = SubtractVectors (ctrl->cpos, right_vector);
    double left_y = Course.FindYCoord (left_wing.x, left_wing.z);
    double right_y = Course.FindYCoord (right_wing.x, right_wing.z);

	if (fabs(left_y-right_y) > MAX_TRACK_DEPTH) {
		break_track_marks();
		return;
    }

    TPlane surf_plane = Course.GetLocalCoursePlane (ctrl->cpos);
    double dist_from_surface = DistanceToPlane (surf_plane, ctrl->cpos);
	// comp_depth = get_compression_depth(Snow);
	double comp_depth = 0.1;
    if (dist_from_surface >= (2 * comp_depth)) {
		break_track_marks();
		return;
    }

	if(track_marks.quads.size() < MAX_TRACK_MARKS)
		track_marks.quads.push_back(track_quad_t());
	list<track_quad_t>::iterator qprev = track_marks.current_mark;
	if(track_marks.current_mark == track_marks.quads.end())
		track_marks.current_mark = track_marks.quads.begin();
	else
		track_marks.current_mark = incrementRingIterator(track_marks.current_mark);
	list<track_quad_t>::iterator q = track_marks.current_mark;

    if (!continuing_track) {
		q->track_type = TRACK_HEAD;
		q->v1 = TVector3 (left_wing.x, left_y + TRACK_HEIGHT, left_wing.z);
		q->v2 = TVector3 (right_wing.x, right_y + TRACK_HEIGHT, right_wing.z);
		q->v3 = TVector3 (left_wing.x, left_y + TRACK_HEIGHT, left_wing.z);
		q->v4 = TVector3 (right_wing.x, right_y + TRACK_HEIGHT, right_wing.z);
		q->n1 = Course.FindCourseNormal (q->v1.x, q->v1.z);
		q->n2 = Course.FindCourseNormal (q->v2.x, q->v2.z);
		q->t1 = TVector2(0.0, 0.0);
		q->t2 = TVector2(1.0, 0.0);
    } else {
		q->track_type = TRACK_TAIL;
		if (qprev != track_marks.quads.end()) {
		    q->v1 = qprev->v3;
	    	q->v2 = qprev->v4;
		    q->n1 = qprev->n3;
		    q->n2 = qprev->n4;
		    q->t1 = qprev->t3;
		    q->t2 = qprev->t4;
	if (qprev->track_type == TRACK_TAIL) qprev->track_type = TRACK_MARK;
		}
		q->v3 = TVector3 (left_wing.x, left_y + TRACK_HEIGHT, left_wing.z);
		q->v4 = TVector3 (right_wing.x, right_y + TRACK_HEIGHT, right_wing.z);
		q->n3 = Course.FindCourseNormal (q->v3.x, q->v3.z);
		q->n4 = Course.FindCourseNormal (q->v4.x, q->v4.z);
		double tex_end = speed*g_game.time_step/TRACK_WIDTH;
		if (q->track_type == TRACK_HEAD) {
		    q->t3= TVector2 (0.0, 1.0);
		    q->t4= TVector2 (1.0, 1.0);
		} else {
		    q->t3 = TVector2 (0.0, q->t1.y + tex_end);
		    q->t4 = TVector2 (1.0, q->t2.y + tex_end);
		}
    }
    q->alpha = min ((2*comp_depth-dist_from_surface)/(4*comp_depth), 1.0);
    continuing_track = true;
}
Ejemplo n.º 13
0
void fillCategory(EventTree* tree, TH1F* hist, double weight){
	int EleP = 0;
	int EleM = 0;
	int MuP = 0;
	int MuM = 0;
	int TauP = 0;
	int TauM = 0;
	int ElePfid = 0;
	int EleMfid = 0;
	int MuPfid = 0;
	int MuMfid = 0;
	int nNufid = 0;

	int nPhofid = 0;
	int nJetfid = 0;
	int nBJetfid = 0;

	TVector2 MET = TVector2(0,0);
	TVector2 tempNu = TVector2(0,0);

	for( int mcI = 0; mcI < tree->nMC_; ++mcI){
	  if(abs(tree->mcMomPID->at(mcI))==24 && tree->mcParentage->at(mcI)==10){
	    if( tree->mcPID->at(mcI) == 11 ) EleP = 1;
	    if( tree->mcPID->at(mcI) == -11 ) EleM = 1;
	    if( tree->mcPID->at(mcI) == 13 ) MuP = 1;
	    if( tree->mcPID->at(mcI) == -13 ) MuM = 1;
	    if( tree->mcPID->at(mcI) == 15) TauP = 1;
	    if( tree->mcPID->at(mcI) == -15) TauM = 1;
	  }
	  if((abs(tree->mcMomPID->at(mcI))==24 && tree->mcParentage->at(mcI)==10) || (abs(tree->mcMomPID->at(mcI))==15 && tree->mcParentage->at(mcI)==26)){		  
	    if( tree->mcPID->at(mcI) == 11 ) {
	      if (tree->mcPt->at(mcI) > 35 && (fabs(tree->mcEta->at(mcI)) < 2.5 && !(fabs(tree->mcEta->at(mcI)) > 1.4442 && fabs(tree->mcEta->at(mcI))<1.566))) ElePfid += 1;
	    }
	    if( tree->mcPID->at(mcI) == -11 ) {
	      if (tree->mcPt->at(mcI) > 35 && (fabs(tree->mcEta->at(mcI)) < 2.5 && !(fabs(tree->mcEta->at(mcI)) > 1.4442 && fabs(tree->mcEta->at(mcI))<1.566))) EleMfid += 1;
	    }
	    if( tree->mcPID->at(mcI) == 13 ) {
	      if (tree->mcPt->at(mcI) > 26 && fabs(tree->mcEta->at(mcI)) < 2.1) MuPfid += 1;
	    }
	    if( tree->mcPID->at(mcI) == -13 ) {
	      if (tree->mcPt->at(mcI) > 26 && fabs(tree->mcEta->at(mcI)) < 2.1) MuMfid += 1;
	    }
	  }
	  if( fabs(tree->mcPID->at(mcI)) == 12 || fabs(tree->mcPID->at(mcI)) == 14 || fabs(tree->mcPID->at(mcI)) == 16 ) {
	    if (tree->mcPt->at(mcI) > 20){
	      nNufid += 1;
	      //cout << nNufid << "\t" << tree->run_ << tree->lumis_ << tree->event_ << "\t" << mcI << "\t" <<  tree->mcPt->at(mcI) << "\t" << tree->mcEta->at(mcI) << "\t" << tree->mcPhi->at(mcI) << endl;
	    }
	    tempNu.SetMagPhi(tree->mcPt->at(mcI),tree->mcPhi->at(mcI));
	    MET += tempNu;
	    //	    cout << nNufid << "\t" << tree->run_ << tree->lumis_ << tree->event_ << "\t" << mcI << "\t" << tree->mcPID->at(mcI) << "\t" <<  tree->mcPt->at(mcI) << "\t" << tree->mcEta->at(mcI) << "\t" << tree->mcPhi->at(mcI) << "\t" << MET.Mod() << endl;
	  }

	  if(tree->mcPID->at(mcI) == 22 && 
	     (tree->mcParentage->at(mcI)==2 || tree->mcParentage->at(mcI)==10 || tree->mcParentage->at(mcI)==26) && 
	     tree->mcPt->at(mcI) > 25 && 
	     fabs(tree->mcEta->at(mcI)) < 1.4442){
	    nPhofid += 1;
	  }

	  if( abs(tree->mcPID->at(mcI)) < 6 && (abs(tree->mcMomPID->at(mcI))==24 || abs(tree->mcMomPID->at(mcI))==6 ) && tree->mcPt->at(mcI) > 30 && abs(tree->mcEta->at(mcI))<2.4 ) {
	    nJetfid += 1;
	    if (abs(tree->mcMomPID->at(mcI))==6 && abs(tree->mcPID->at(mcI))==5){
	      nBJetfid += 1;
	    }
	  }
	}
	
	hist->Fill(1.0, weight); // Total
	int nEle = EleP + EleM;
	int nMu = MuP + MuM;
	int nTau = TauP + TauM;
	if( nEle + nMu + nTau == 0) hist->Fill(2.0, weight); // All Had
	if( nEle + nMu + nTau == 1) hist->Fill(3.0, weight); // Single Lepton
	if( nEle + nMu + nTau == 2) hist->Fill(4.0, weight); // Di Lepton

	int nElefid = ElePfid + EleMfid;
	int nMufid = MuPfid + MuMfid;

	if ( nEle==1 && nMu==0 && nTau==0 ) hist->Fill(6.0, weight);
	if ( nEle==0 && nMu==1 && nTau==0 ) hist->Fill(7.0, weight);
	if ( nEle==0 && nMu==0 && nTau==1 ) hist->Fill(8.0, weight);
	if ( nElefid==1 && nMufid==0) hist->Fill(9.0, weight); //Ejets final state (generated)
	if ( nElefid==0 && nMufid==1) hist->Fill(10.0, weight); //Mujets final state (generated)

	// if ( nElefid==1 && nMufid==0) hist->Fill(6.0, weight); //Ejets final state (generated)
	// if ( nElefid==2 && nMufid==0) hist->Fill(7.0, weight); //Ejets final state (generated)
	// if ( nElefid==0 && nMufid==1) hist->Fill(8.0, weight); //Mujets final state (generated)
	// if ( nElefid==0 && nMufid==2) hist->Fill(9.0, weight); //Ejets final state (generated)
	// if ( nElefid==1 && nMufid==1) hist->Fill(10.0, weight); //Ejets final state (generated)

	int nJetsfid = 0;
	int nBJetsfid = 0;
	
	if ((nElefid + nMufid)==1){
	  // for ( int jetI = 0; jetI < tree->genJetPt_->size(); jetI++){
	  //   if (tree->genJetPt_->at(jetI) >= 30 && fabs(tree->genJetEta_->at(jetI)) < 2.4) nJetsfid += 1;	    
	  // }
	  for ( int jetI = 0; jetI < tree->nJet_; jetI++){
	    //	    if (tree->jetGenPt_->at(jetI) >= 30 && fabs(tree->jetGenEta_->at(jetI)) < 2.4) nJetsfid += 1;
	    if (tree->jetGenJetPt_->at(jetI) >= 30 && fabs(tree->jetGenEta_->at(jetI)) < 2.4){
	      nJetsfid += 1;
	      if (abs(tree->jetGenPartonID_->at(jetI))==5) nBJetsfid += 1;
	    }
	  }
	}


	if(nElefid==1 && nMufid==0 && nJetsfid >=3){
	  hist->Fill(11.0, weight);
	  if (nBJetsfid >= 1){
	    hist->Fill(12.0, weight);
	    if (MET.Mod() > 20){
	      //	    if (tree->genMET_ > 20){
	      hist->Fill(13.0, weight);
	      if (nPhofid > 0) hist->Fill(14.0, weight);
	    }
	  }
	}


	// //TESTING
	// if(nElefid==0 && nMufid==1 && nJetsfid >=3){
	//   hist->Fill(11.0, weight);
	//   if (nNufid==1){
	//     hist->Fill(12.0,weight);
	//   }
	//   if (nNufid > 0){
	//     hist->Fill(13.0, weight);
	//   }
	//   if (MET.Mod() > 20) hist->Fill(14.0,weight);
	//   if (nBJetsfid >= 1){
	//     //	    hist->Fill(12.0, weight);
	//     if (tree->genMET_ > 20){
	//       //	      hist->Fill(13.0, weight);
	//       // if (nPhofid > 0) hist->Fill(14.0, weight);
	//     }
	//   }
	// }

	if(nElefid==0 && nMufid==1 && nJetsfid >=3){
	  hist->Fill(16.0, weight);
	  if (nBJetsfid >= 1){
	    hist->Fill(17.0, weight);
	    //	    if (tree->genMET_ > 20){
	    if (MET.Mod() > 20){
	      hist->Fill(18.0, weight);
	      if (nPhofid > 0) hist->Fill(19.0, weight);
	    }
	  }
	}
	// if(nElefid==0 && nMufid==1 && nJetfid >=3 && nBJetfid >= 1 && nNufid == 1) {
	//   hist->Fill(12.0, weight);
	//   if (nPhofid > 0) hist->Fill(15.0, weight);
	// }

	// if(nElefid==1 && nMufid==0 && nJetsfid >=3 && nNufid == 1){
	//   hist->Fill(11.0, weight);
	//   if (nPhofid > 0) hist->Fill(14.0, weight);
	// }
	// if(nElefid==0 && nMufid==1 && nJetsfid >=3 && nNufid == 1) {
	//   hist->Fill(12.0, weight);
	//   if (nPhofid > 0) hist->Fill(15.0, weight);
	// }

	return;
}