// see: https://twiki.cern.ch/twiki/bin/view/CMS/SWGuideMuonIdRun2
//   since Run I: changed PFISO cut from 0.12 to 0.15
bool Muon::PassUserID_MuonTight_PFIso04 ( bool verbose ){

  double pfiso04 = ( PFIsoR04ChargedHadron() + std::max (0., PFIsoR04NeutralHadron() + PFIsoR04Photon() - ( 0.5 * PFIsoR04PU() ))) / Pt();
  
  bool pass_isGlobal  = bool ( IsGlobal()                   == 1   );
  bool pass_isPF      = bool ( IsPFMuon()                   == 1   );
  bool pass_chi2      = bool ( GlobalChi2 ()                 < 10. );
  bool pass_muonHits  = bool ( GlobalTrkValidHits()          > 0   );
  bool pass_stations  = bool ( StationMatches()              > 1   );
  bool pass_dxy       = bool ( fabs(BestTrackVtxDistXY())    < 0.2 );
  bool pass_dz        = bool ( fabs(BestTrackVtxDistZ ())    < 0.5 );
  bool pass_pixelHits = bool ( TrkPixelHits()                > 0   );
  bool pass_trkLayers = bool ( TrackLayersWithMeasurement()  > 5   );
  bool pass_pfiso04   = bool ( pfiso04                       < 0.15);
  
  bool decision = ( pass_isGlobal  && 
		    pass_isPF      && 
		    pass_chi2      && 
		    pass_muonHits  && 
		    pass_stations  && 
		    pass_dxy       && 
		    pass_dz        && 
		    pass_pixelHits && 
		    pass_trkLayers && 
		    pass_pfiso04   );
  
  return decision;
}
Exemple #2
0
static void polygon(int cnt[], double *pts[], Windrule w, int v){
	Edge *edges, *ep, *nextep, **ylist, **eylist, **yp;
	Point p, q, p0, p1, p10;
	int i, dy, nbig, y, left, right, wind, nwind, nvert;
	int *cntp;
	double **ptsp, *xp;
	nvert=0;
	for(cntp=cnt;*cntp;cntp++) nvert+=*cntp;
	edges=(Edge *)malloc(nvert*sizeof(Edge));
	if(edges==0){
	NoSpace:
		fprintf(stderr, "polygon: no space\n");
		exits("malloc failed");
	}
	ylist=(Edge **)malloc(Dy(screen->r)*sizeof(Edge *));
	if(ylist==0) goto NoSpace;
	eylist=ylist+Dy(screen->r);
	for(yp=ylist;yp!=eylist;yp++) *yp=0;
	ep=edges;
	for(cntp=cnt,ptsp=pts;*cntp;cntp++,ptsp++){
		p.x=SCX((*ptsp)[*cntp*2-2]);
		p.y=SCY((*ptsp)[*cntp*2-1]);
		nvert=*cntp;
		for(xp=*ptsp,i=0;i!=nvert;xp+=2,i++){
			q=p;
			p.x=SCX(xp[0]);
			p.y=SCY(xp[1]);
			if(p.y==q.y) continue;
			if(p.y<q.y){
				p0=p;
				p1=q;
				ep->dwind=1;
			}
			else{
				p0=q;
				p1=p;
				ep->dwind=-1;
			}
			if(p1.y<=screen->r.min.y) continue;
			if(p0.y>=screen->r.max.y) continue;
			ep->p=p0;
			if(p1.y>screen->r.max.y)
				ep->maxy=screen->r.max.y;
			else
				ep->maxy=p1.y;
			p10=subpt(p1, p0);
			if(p10.x>=0){
				ep->dx=p10.x/p10.y;
				ep->dx1=ep->dx+1;
			}
			else{
				p10.x=-p10.x;
				ep->dx=-(p10.x/p10.y); /* this nonsense rounds toward zero */
				ep->dx1=ep->dx-1;
			}
			ep->x=0;
			ep->num=p10.x%p10.y;
			ep->den=p10.y;
			if(ep->p.y<screen->r.min.y){
				dy=screen->r.min.y-ep->p.y;
				ep->x+=dy*ep->num;
				nbig=ep->x/ep->den;
				ep->p.x+=ep->dx1*nbig+ep->dx*(dy-nbig);
				ep->x%=ep->den;
				ep->p.y=screen->r.min.y;
			}
			insert(ep, ylist+(ep->p.y-screen->r.min.y));
			ep++;
		}
	}
	left = 0;
	for(yp=ylist,y=screen->r.min.y;yp!=eylist;yp++,y++){
		wind=0;
		for(ep=*yp;ep;ep=nextep){
			nwind=wind+ep->dwind;
			if(nwind&w){	/* inside */
				if(!(wind&w)){
					left=ep->p.x;
					if(left<screen->r.min.x) left=screen->r.min.x;
				}
			}
			else if(wind&w){
				right=ep->p.x;
				if(right>=screen->r.max.x) right=screen->r.max.x;
#define BART_BUG_FIXED	/* what goes on here?? -rob */
#ifdef BART_BUG_FIXED
				if(right>left)
					line(screen, Pt(left, y), Pt(right, y), Endsquare, Endsquare, 0, getcolor(v), ZP);
#else
				if(right>left){
					switch(v){
					default:
						segment(&screen, Pt(left, y), Pt(right, y),
							~0, D&~S);
						segment(&screen, Pt(left, y), Pt(right, y),
							v, f);
						break;
					case 0:
						segment(&screen, Pt(left, y), Pt(right, y),
							~0, D&~S);
						break;
					case 3:
						segment(&screen, Pt(left, y), Pt(right, y),
							v, f);
						break;
					}
				}
#endif
			}
			wind=nwind;
			nextep=ep->next;
			if(++ep->p.y!=ep->maxy){
				ep->x+=ep->num;
				if(ep->x>=ep->den){
					ep->x-=ep->den;
					ep->p.x+=ep->dx1;
				}
				else
					ep->p.x+=ep->dx;
				insert(ep, yp+1);
			}
		}
	}
	free((char *)edges);
	free((char *)ylist);
}
Exemple #3
0
Window*
coladd(Column *c, Window *w, Window *clone, int y)
{
	Rectangle r, r1;
	Window *v;
	int i, t;

	v = nil;
	r = c->r;
	r.min.y = c->tag.r.max.y+Border;
	if(y<r.min.y && c->nw>0){	/* steal half of last window by default */
		v = c->w[c->nw-1];
		y = v->body.r.min.y+Dy(v->body.r)/2;
	}
	/* look for window we'll land on */
	for(i=0; i<c->nw; i++){
		v = c->w[i];
		if(y < v->r.max.y)
			break;
	}
	if(c->nw > 0){
		if(i < c->nw)
			i++;	/* new window will go after v */
		/*
		 * if v's too small, grow it first.
		 */
		if(!c->safe || v->body.maxlines<=3){
			colgrow(c, v, 1);
			y = v->body.r.min.y+Dy(v->body.r)/2;
		}
		r = v->r;
		if(i == c->nw)
			t = c->r.max.y;
		else
			t = c->w[i]->r.min.y-Border;
		r.max.y = t;
		draw(screen, r, textcols[BACK], nil, ZP);
		r1 = r;
		y = min(y, t-(v->tag.font->height+v->body.font->height+Border+1));
		r1.max.y = min(y, v->body.r.min.y+v->body.nlines*v->body.font->height);
		r1.min.y = winresize(v, r1, FALSE);
		r1.max.y = r1.min.y+Border;
		draw(screen, r1, display->black, nil, ZP);
		r.min.y = r1.max.y;
	}
	if(w == nil){
		w = emalloc(sizeof(Window));
		w->col = c;
		draw(screen, r, textcols[BACK], nil, ZP);
		wininit(w, clone, r);
	}else{
		w->col = c;
		winresize(w, r, FALSE);
	}
	w->tag.col = c;
	w->tag.row = c->row;
	w->body.col = c;
	w->body.row = c->row;
	c->w = realloc(c->w, (c->nw+1)*sizeof(Window*));
	memmove(c->w+i+1, c->w+i, (c->nw-i)*sizeof(Window*));
	c->nw++;
	c->w[i] = w;
	savemouse(w);
	/* near but not on the button */
	moveto(mousectl, addpt(w->tag.scrollr.max, Pt(3, 3)));
	barttext = &w->body;
	c->safe = TRUE;
	return w;
}
Exemple #4
0
bool Electron::PassUserID_EGamma ( ID id, bool verbose ){

  //----------------------------------------------------------------------
  // Barrel electron cut values
  //----------------------------------------------------------------------
  // See: https://twiki.cern.ch/twiki/bin/viewauth/CMS/CutBasedElectronIdentificationRun2
  double l_b_f5x5sieie   [4] = {0.011100, 0.010557, 0.010399, 0.010181 };
  double l_b_dEtaIn      [4] = {0.016315, 0.012442, 0.007641, 0.006574 };
  double l_b_dPhiIn      [4] = {0.252044, 0.072624, 0.032643, 0.022868 };
  double l_b_hoe         [4] = {0.345843, 0.121476, 0.060662, 0.037553 };
  double l_b_pfRelIso    [4] = {0.164369, 0.120026, 0.097213, 0.074355 };
  double l_b_ooemoop     [4] = {0.248070, 0.221803, 0.153897, 0.131191 };
  double l_b_d0          [4] = {0.060279, 0.022664, 0.011811, 0.009924 };
  double l_b_dZ          [4] = {0.800538, 0.173670, 0.070775, 0.015310 };
  int    l_b_missHits    [4] = {2,   1,   1,   1}; 

  //----------------------------------------------------------------------
  // Endcap electron cut values
  //----------------------------------------------------------------------
  double l_e_f5x5sieie   [4] = {0.033987,  0.032602,  0.029524,  0.028766 };
  double l_e_dEtaIn      [4] = {0.010671,  0.010654,  0.009285,  0.005681 };
  double l_e_dPhiIn      [4] = {0.245263,  0.145129,  0.042447,  0.032046 };
  double l_e_hoe         [4] = {0.134691,  0.131862,  0.104263,  0.081902 };
  double l_e_pfRelIso    [4] = {0.212604,  0.162914,  0.116708,  0.090185 };
  double l_e_ooemoop     [4] = {0.157160,  0.142283,  0.137468,  0.106055 };
  double l_e_d0          [4] = {0.273097,  0.097358,  0.051682,  0.027261 };
  double l_e_dZ          [4] = {0.885860,  0.198444,  0.180720,  0.147154 };
  int    l_e_missHits    [4] = {3,   1,   1,   1}; 
  
  
  //----------------------------------------------------------------------
  // Bools that depend on barrel vs. endcap
  //----------------------------------------------------------------------

  bool   pass_full5x5SigmaIetaIeta = false;
  bool   pass_deltaEta             = false;
  bool   pass_deltaPhi             = false;
  bool   pass_hoe                  = false;
  bool   pass_pfIsoWBetaOverPt     = false;
  bool   pass_ooEmooP              = false;
  bool   pass_vtxDistXY            = false; // aka d0
  bool   pass_vtxDistZ             = false;
  bool   pass_missingHits          = false;
  bool   pass_convVeto             = false;

  //----------------------------------------------------------------------
  // Define EGamma ep parameter
  //----------------------------------------------------------------------
  const float ecal_energy_inverse = 1.0/EcalEnergy();
  const float eSCoverP = ESuperClusterOverP();
  const float ooEmooP = std::abs(1.0 - eSCoverP)*ecal_energy_inverse;

  //----------------------------------------------------------------------
  // Define DeltaBeta PF Isolation
  //----------------------------------------------------------------------
  double ptCutoff = 20.0;
  double deltaBetaConstant = 0.5;
  bool relativeIso = true;
  //
  const float chad = PFChargedHadronIso03();
  const float nhad = PFNeutralHadronIso03();
  const float pho = PFPhotonIso03();
  const float puchad = PFPUIso03();
  float iso = chad + std::max(0.0, nhad + pho - deltaBetaConstant*puchad);
  if(relativeIso) iso /= Pt();
  
  //----------------------------------------------------------------------
  // Barrel electron test
  //----------------------------------------------------------------------

  if ( fabs(SCEta()) < 1.479 ){
    pass_full5x5SigmaIetaIeta = bool ( Full5x5SigmaIEtaIEta() < l_b_f5x5sieie [ id ] );
    pass_deltaEta             = bool ( fabs(DeltaEta())       < l_b_dEtaIn    [ id ] );
    pass_deltaPhi             = bool ( fabs(DeltaPhi())       < l_b_dPhiIn    [ id ] );
    pass_hoe                  = bool ( HoE()                  < l_b_hoe       [ id ] );
    pass_pfIsoWBetaOverPt     = bool ( ooEmooP                < l_b_ooemoop   [ id ] );
    pass_ooEmooP              = bool ( iso                    < l_b_pfRelIso  [ id ] );
    pass_vtxDistXY            = bool ( fabs(VtxDistXY())      < l_b_d0        [ id ] );
    pass_vtxDistZ             = bool ( fabs(VtxDistZ ())      < l_b_dZ        [ id ] );
    pass_missingHits          = bool ( MissingHits()          < l_b_missHits  [ id ] );
    pass_convVeto             = ! HasMatchedConvPhot();
  } 

  //----------------------------------------------------------------------
  // Endcap electron test
  //----------------------------------------------------------------------

  else if ( fabs(SCEta()) > 1.479 && fabs(SCEta()) < 2.5 ){ 
    pass_full5x5SigmaIetaIeta = bool ( Full5x5SigmaIEtaIEta() < l_e_f5x5sieie [ id ] );
    pass_deltaEta             = bool ( fabs(DeltaEta())       < l_e_dEtaIn    [ id ] );
    pass_deltaPhi             = bool ( fabs(DeltaPhi())       < l_e_dPhiIn    [ id ] );
    pass_hoe                  = bool ( HoE()                  < l_e_hoe       [ id ] );
    pass_pfIsoWBetaOverPt     = bool ( ooEmooP                < l_e_ooemoop   [ id ] );
    pass_ooEmooP              = bool ( iso                    < l_e_pfRelIso  [ id ] );
    pass_vtxDistXY            = bool ( fabs(VtxDistXY())      < l_e_d0        [ id ] );
    pass_vtxDistZ             = bool ( fabs(VtxDistZ ())      < l_e_dZ        [ id ] );
    pass_missingHits          = bool ( MissingHits()          < l_e_missHits  [ id ] );
    pass_convVeto             = ! HasMatchedConvPhot();
  }

  bool decision = ( 
    pass_full5x5SigmaIetaIeta && 
    pass_deltaEta             && 
    pass_deltaPhi             && 
    pass_hoe                  && 
    pass_pfIsoWBetaOverPt     && 
    pass_ooEmooP              && 
    pass_vtxDistXY            && 
    pass_vtxDistZ             && 
    pass_missingHits          && 
    pass_convVeto             );
  
  return decision;
  
}