Exemplo n.º 1
0
// does the two-step clustering algorithm:
// first make a subset of the data, to SubPoints points
// then run CEM on this
// then use these clusters to do a CEM on the full data
float KK::Cluster() {
	KK KKSub;
	int i, d, p;
	//float StepSize; // for resampling
	int sPoints; // number of points to subset to

	if (Subset<=1) { // don't subset
		Output("--- Clustering full data set of %d points ---\n", nPoints);
		return CEM(NULL, 1, 1);
	} else { // run on a subset of points

		sPoints = nPoints/Subset; // number of subset points - integer division will round down

		// set up KKSub object
		KKSub.nDims = nDims;
		KKSub.nPoints = sPoints;
		KKSub.penaltyMix = PenaltyMix;
		KKSub.nStartingClusters = nStartingClusters;
		KKSub.AllocateArrays();

		// fill KKSub with a subset of SubPoints from full data set.
		for (i=0; i<sPoints; i++) {
			// choose point to include, evenly spaced plus a random offset
			p= Subset*i + irand(0,Subset-1);

			// copy data
			for (d=0; d<nDims; d++) KKSub.Data[i*nDims + d] = Data[p*nDims + d];
		}

		// run CEM algorithm on KKSub
		Output("--- Running on subset of %d points ---\n", sPoints);
		KKSub.CEM(NULL, 1, 1);

		// now copy cluster shapes from KKSub to main KK
		Weight = KKSub.Weight;
		Mean = KKSub.Mean;
		Cov = KKSub.Cov;
		ClassAlive = KKSub.ClassAlive;
		nClustersAlive = KKSub.nClustersAlive;
		AliveIndex = KKSub.AliveIndex;

		// Run E and C steps on full data set
		Output("--- Evaluating fit on full set of %d points ---\n", nPoints);
		EStep();
		CStep();

		// compute score on full data set and leave
		return ComputeScore();
	}
}
Exemplo n.º 2
0
//_____________________________________________________________________________//
void study(int type, bool wBkg){
  string slep="_ee";
  string SLEP="_EE_";
  if(type==1){
    slep = "_mm";
    SLEP = "_MM_";
  }
  if(type==2){
    slep = "_em";
    SLEP = "_EM_";
  }

  TCut EE("llType==0");
  TCut MM("llType==1");
  TCut EM("llType==2");


  //
  //start modif
  //
  bool logy=false;//true;

  TCut SJ("j_isC20 || j_isB20 || j_isF30");

  TCut SEL("nSJets>=0 ");
  //TCut SEL("nSJets>0 && metrel>60 ");
  //TCut SEL(SJ && "nSJets==1 && (mll>100 & mll<110) && l_pt[0]>30 ");
  //TCut SEL("nSJets==1 && metrel>40 && (mll>100 & mll<110) ");
  //TCut SEL("nSJets==1 && met>40 && l_pt[0]>30");
  //TCut SEL("nSJets==1 && metrel>40");
  //TCut SEL("nSJets==1 && metrel>40 && l_pt[0]>30");
  //TCut SEL(SJ && "nSJets==1 && metrel>40 && l_pt[0]>30 && (mll>100 & mll<110)");
  //TCut SEL(SJ && "nSJets==1 && l_pt[0]>30 && (mll>100 & mll<110)");
  //TCut SEL("nSJets==1 && metrel>40 && mll>90 & mll<120 && l_pt[0]");
  //TCut SEL("nSJets<2 && metrel>40 ");

  //string var = "l_pt[1]";
  //string var = "l_q[0]+l_q[1]";
  //string var = "sqrt(2*l_pt[0]*met * (1- cos(acos(cos(l_phi[0]-met_phi)))))";
  //  string var = "mll";
  //string var = "pTll";
  //string var = "met";
  string var = "metrel";
  //string var = "met_refEle";
  //string var = "met_refMuo";
  //string var = "met_refJet";
  //string var = "met_cellout";
  //  string var = "acos(cos(l_phi[1]-met_phi))";
  //string var = "nSJets";
  //string var = "j_pt";
  //string var = "j_eta";
  //string var = "j_jvf";

  string sName = "CR2LepSS_noCut"+ SLEP + var;
  //string sName = "CR2LepSS_VR1SS"+ SLEP + var;
  //string sName = "CR2LepSS_Jveto"+ SLEP + var;
  //string sName = "CR2LepSS_ge1SJ_metrel70"+ SLEP + var;
  //string sName = "CR2LepSS_1Jptl030Mll100-110"+ SLEP + var;
  //string sName = "CR2LepSS_1JMetrel40"+ SLEP + var;
  //string sName = "CR2LepSS_Metrel40Mll100-110"+ SLEP + var;
  //string sName = "CR2LepSS_1JMet40ptl030"+ SLEP + var;
  //  string sName = "CR2LepSS_1JMetrel40"+ SLEP + var;
  //string sName = "CR2LepSS_1JMetrel40ptl030"+ SLEP + var;
  //string sName = "CR2LepSS_LE1JMetrel40"+ SLEP + var;
  //string sName = "CR2LepSS_1JMetrel40Mll90-120"+ SLEP + var;
  //  string sName = "CR2LepSS_1JMetrel40ptl030mll102-106"+ SLEP + var;
  //string sName = "CR2LepSS_1JMetrel40ptl030mll100-110"+ SLEP + var;

  //string sName = "CR2LepSS_1Jptl030IN"+ SLEP + var;
  //string sName = "CR2LepSS_1JMetrel40ptl030IN"+ SLEP + var;
  //string sName = "CR2LepSS_1JMetrel40ptl030OUT"+ SLEP + var;

  //
  //end modif
  //


  //No changes needed below
  string hName ="hdata"+slep;

  TH1F* hdata = bookHist(var,hName);
  if(hdata==NULL) abort();

  TCut CEE( (SEL && EE  ) * "w");
  TCut CMM( (SEL && MM  ) * "w");
  TCut CEM( (SEL && EM  ) * "w");

  if(wBkg){
    TH1F* hFake = (TH1F*)  hdata->Clone();
    hFake->SetTitle(string("hFake"+slep).c_str());
    hFake->SetName(string("hFake"+slep).c_str());

    TH1F* hWW = (TH1F*)  hdata->Clone();
    hWW->SetTitle(string("hWW"+slep).c_str());
    hWW->SetName(string("hWW"+slep).c_str());

    TH1F* hWZ = (TH1F*)  hdata->Clone();
    hWZ->SetTitle(string("hWZ"+slep).c_str());
    hWZ->SetName(string("hWZ"+slep).c_str());

    TH1F* hZZ = (TH1F*)  hdata->Clone();
    hZZ->SetTitle(string("hZZ"+slep).c_str());
    hZZ->SetName(string("hZZ"+slep).c_str());

    TH1F* hTOP = (TH1F*)  hdata->Clone();
    hTOP->SetTitle(string("hTOP"+slep).c_str());
    hTOP->SetName(string("hTOP"+slep).c_str());

    TH1F* hZJET = (TH1F*)  hdata->Clone();
    hZJET->SetTitle(string("hZJET"+slep).c_str());
    hZJET->SetName(string("hZJET"+slep).c_str());
  }


  //Fill histo
  if(type==0){
    string cmd1 = var + ">>hdata_ee";
    c_data->Draw(cmd1.c_str(),CEE,"goff");
    if(wBkg){
      cmd1 = var + ">>hFake_ee";
      c_fake->Draw(cmd1.c_str(),CEE,"goff");
      cmd1 = var + ">>hWW_ee";
      c_WW->Draw(cmd1.c_str(),CEE,"goff");
      cmd1 = var + ">>hWZ_ee";
      c_WZ->Draw(cmd1.c_str(),CEE,"goff");
      cmd1 = var + ">>hZZ_ee";
      c_ZZ->Draw(cmd1.c_str(),CEE,"goff");
      cmd1 = var + ">>hTOP_ee";
      c_TOP->Draw(cmd1.c_str(),CEE,"goff");
      cmd1 = var + ">>hZJET_ee";
      c_ZJET->Draw(cmd1.c_str(),CEE,"goff");
    }
  }
  else if (type==1) {
    string cmd1 = var + ">>hdata_mm";
    c_data->Draw(cmd1.c_str(),CMM,"goff");
    if(wBkg){
      cmd1 = var + ">>hFake_mm";
      c_fake->Draw(cmd1.c_str(),CMM,"goff");
      cmd1 = var + ">>hWW_mm";
      c_WW->Draw(cmd1.c_str(),CMM,"goff");
      cmd1 = var + ">>hWZ_mm";
      c_WZ->Draw(cmd1.c_str(),CMM,"goff");
      cmd1 = var + ">>hZZ_mm";
      c_ZZ->Draw(cmd1.c_str(),CMM,"goff");
      cmd1 = var + ">>hTOP_mm";
      c_TOP->Draw(cmd1.c_str(),CMM,"goff");
      cmd1 = var + ">>hZJET_mm";
      c_ZJET->Draw(cmd1.c_str(),CMM,"goff");
    }
  }
 else if (type==2) {
    string cmd1 = var + ">>hdata_em";
    c_data->Draw(cmd1.c_str(),CEM,"goff");
    if(wBkg){
      cmd1 = var + ">>hFake_em";
      c_fake->Draw(cmd1.c_str(),CEM,"goff");
      cmd1 = var + ">>hWW_em";
      c_WW->Draw(cmd1.c_str(),CEM,"goff");
      cmd1 = var + ">>hWZ_em";
      c_WZ->Draw(cmd1.c_str(),CEM,"goff");
      cmd1 = var + ">>hZZ_em";
      c_ZZ->Draw(cmd1.c_str(),CEM,"goff");
      cmd1 = var + ">>hTOP_em";
      c_TOP->Draw(cmd1.c_str(),CEM,"goff");
      cmd1 = var + ">>hZJET_em";
      c_ZJET->Draw(cmd1.c_str(),CEM,"goff");
    }
  }

  if(wBkg)   plot(hdata,hFake,hWW,hWZ,hZZ,hTOP,hZJET, sName,logy);
  else       plot(hdata,sName,logy);

}