コード例 #1
0
ファイル: pfm2png.cpp プロジェクト: mzhang94/stereo
// convert float disparity image into a color image using jet colormap
void float2color(CFloatImage fimg, CByteImage &img, float dmin, float dmax)
{
    CShape sh = fimg.Shape();
    int width = sh.width, height = sh.height;
    sh.nBands = 3;
    img.ReAllocate(sh);

    float scale = 1.0 / (dmax - dmin);

    for (int y = 0; y < height; y++) {
	for (int x = 0; x < width; x++) {
	    float f = fimg.Pixel(x, y, 0);
	    int r = 0;
	    int g = 0;
	    int b = 0;
	    
	    if (f != INFINITY) {
		float val = scale * (f - dmin);
		jet(val, r, g, b);
	    }

	    img.Pixel(x, y, 0) = b;
	    img.Pixel(x, y, 1) = g;
	    img.Pixel(x, y, 2) = r;
	}
    }
}
コード例 #2
0
ファイル: jet.cpp プロジェクト: daniel-perry/libigl
IGL_INLINE void igl::jet(
  const Eigen::PlainObjectBase<DerivedZ> & Z,
  const bool normalize,
  Eigen::PlainObjectBase<DerivedC> & C)
{
  const double min_z = (normalize?Z.minCoeff():0);
  const double max_z = (normalize?Z.maxCoeff():-1);
  return jet(Z,min_z,max_z,C);
}
コード例 #3
0
ファイル: jet.cpp プロジェクト: daniel-perry/libigl
IGL_INLINE void igl::jet(
  const Eigen::PlainObjectBase<DerivedZ> & Z,
  const double min_z,
  const double max_z,
  Eigen::PlainObjectBase<DerivedC> & C)
{
  C.resize(Z.rows(),3);
  for(int r = 0;r<Z.rows();r++)
  {
    jet((-min_z+Z(r,0))/(max_z-min_z),C(r,0),C(r,1),C(r,2));
  }
}
コード例 #4
0
ファイル: ConeSplitMerge.hpp プロジェクト: Dr15Jones/fastjet
ConeSplitMerge<Item>::ConeSplitMerge(const std::vector<ProtoJet<Item> >& jvector) 
{
  // sort proto_jets in Et descending order
  typename std::vector<ProtoJet<Item> >::const_iterator jt;
  for(jt = jvector.begin(); jt != jvector.end(); ++jt) 
  {
    // this is supposed to be a stable cone, declare so
    ProtoJet<Item> jet(*jt);
    jet.NowStable();
    _members.insert(std::make_pair(jet,jet.pT()));
  }
}
コード例 #5
0
ファイル: animations.c プロジェクト: eehhgg/OpenGL
void init(void){
	float luz_ambiente[] = {0.45, 0.45, 0.45, 1.0};
	float luz0_especular[] = {1.0, 1.0, 1.0, 1.0};
	float luz0_difusa[] = {0.35, 0.35, 0.35, 1.0};
	float luz0_posicion[] = {200.0, 200.0, 200.0, 1.0};
	float luz0_direccion[] = {0.0, 0.0, 0.0};
	float reflectancia[] = {0.5, 0.5, 0.5, 1.0};

	float bases[5]={69.6, 63.15, 51.3, 39.5, 35.95};
	float basesT[6]={82.45, 77.4, 64.05, 52.5, 47.25, 30.0};
	float altura=300.0;
	float color1[]= {0.0, 0.0, 0.0, 1.0};
	float color2[]= {0.7, 0.0, 0.0, 1.0};
	float basesX[5], basesTX[6], alturaX;

	ratio=(GLfloat)winWidth/(GLfloat)winHeight;
	Vx=Vz=0.0;		Vy=30.0;		Vtheta=3*PI/2.0;

	glutInitDisplayMode(GLUT_DOUBLE | GLUT_RGB | GLUT_DEPTH);
	glutInitWindowSize(winWidth, winHeight);
	glutInitWindowPosition(30, 50);
	glutCreateWindow("Animacion");

	glShadeModel(GL_SMOOTH);
	glFrontFace(GL_CCW);
	glEnable(GL_DEPTH_TEST);
	glEnable(GL_CULL_FACE);
	glEnable(GL_LIGHTING);
	glLightModelfv(GL_LIGHT_MODEL_AMBIENT,luz_ambiente);
	glEnable(GL_COLOR_MATERIAL);
	glColorMaterial(GL_FRONT, GL_AMBIENT_AND_DIFFUSE);
	glMaterialfv(GL_FRONT, GL_SPECULAR, reflectancia);
	glMateriali(GL_FRONT, GL_SHININESS, 60);

	glLightfv(GL_LIGHT0,GL_DIFFUSE,luz0_difusa);
	glLightfv(GL_LIGHT0,GL_DIFFUSE,luz_ambiente);
	glLightfv(GL_LIGHT0,GL_SPECULAR,luz0_especular);
	glLightfv(GL_LIGHT0,GL_POSITION,luz0_posicion);
	glLightfv(GL_LIGHT0,GL_SPOT_DIRECTION,luz0_direccion);
	glEnable(GL_LIGHT0);

	//lista room
	Lroom=glGenLists(1);	glNewList(Lroom,GL_COMPILE);	room(LADO);		glEndList();
	//lista jet
	Ljet=glGenLists(1);		glNewList(Ljet,GL_COMPILE);		jet();		glEndList();
	//lista castle1
	Lcastle=glGenLists(1);
	copiaVec(basesX,bases,5);			escalaVec(0.1, basesX, 5);
	copiaVec(basesTX,basesT,6);			escalaVec(0.1, basesTX, 6);
	alturaX = 0.1*altura;
	glNewList(Lcastle,GL_COMPILE);		castillo(basesX, basesTX, alturaX, color1, color2);		glEndList();
}
コード例 #6
0
ファイル: ado2.cpp プロジェクト: zxlooong/minica
BOOL CJetEngine::CompactDatabase(CString strDatabaseSource, CString strDatabaseDestination)
{
	try
	{
		::CoInitialize(NULL);
		IJetEnginePtr jet(__uuidof(JetEngine));		
		HRESULT hr = jet->CompactDatabase(_bstr_t(strDatabaseSource.GetBuffer(0)), _bstr_t(strDatabaseDestination.GetBuffer(0)));
		jet.Release();
		::CoUninitialize();
		return hr == S_OK;
	}
	catch(_com_error) 
	{       
		::CoUninitialize();
		return FALSE;
	} 
}
コード例 #7
0
ファイル: ado2.cpp プロジェクト: zxlooong/minica
BOOL CJetEngine::RefreshCache(ADODB::_Connection *pconn)
{
	//Added by [email protected]
	try
	{
		::CoInitialize(NULL);
		IJetEnginePtr jet(__uuidof(JetEngine)); 
		HRESULT hr = jet->RefreshCache(pconn);
		::CoUninitialize();
		return hr == S_OK;
	}
	catch(_com_error) 
	{ 
		::CoUninitialize();
		return FALSE;
	} 
	
	return FALSE;
}
コード例 #8
0
ファイル: Vehicle.cpp プロジェクト: flair2005/Racing-Game
void Vehicle::updataCar(NxReal timeSinceLastFrame)
{
	if(NxMath::abs(mTurnLeft) > 0.001f || NxMath::abs(mTurnRight) > 0.001f)
	{
		mAngleDelta = mTurnLeft + mTurnRight;
	}
	else
		// 车在松开按键的时候会自动回正
		if(NxMath::abs(mAngle) > 0.0001f)
		{
			if(mAngle > 0.0001f)
				mAngleDelta = -mVehicleParam.m_sVehicleParam.SteerSpeed;
			else
				mAngleDelta = mVehicleParam.m_sVehicleParam.SteerSpeed;
		}
		else
			mAngleDelta = 0.f;

	mAngle += mAngleDelta;

	//将轮子角度限制
	mAngle = NxMath::clamp(mAngle, mVehicleParam.m_sVehicleParam.SteerAngleRange,
							-mVehicleParam.m_sVehicleParam.SteerAngleRange);

	Ogre::Real radian = mAngle * 0.01745329f;
	mWheels[TOP_LEFT].mWheel->setSteerAngle(radian);
	mWheels[TOP_RIGHT].mWheel->setSteerAngle(radian);

	mWheels[TOP_LEFT].mWheel->setMotorTorque(mSpeed);
	mWheels[TOP_RIGHT].mWheel->setMotorTorque(mSpeed);
	mWheels[Bottom_LEFT].mWheel->setMotorTorque(mSpeed);
	mWheels[Bottom_RIGHT].mWheel->setMotorTorque(mSpeed);

	//mActor->addForce(tforce, NX_IMPULSE);
	mActor->addTorque(ttortue, NX_IMPULSE);

	if (isJet)
		jet(800);
}
コード例 #9
0
ファイル: prune.C プロジェクト: mousebrains/kayak
int
main (int argc,
      char **argv)
{
  PruneData pd;

  Data data;
  Types::Keys keys(data.allKeys());
  Types::Keys k;
 
  for (Types::Keys::const_iterator it(keys.begin()), et(keys.end()); it != et; ++it) {
    for (int i(Data::FLOW); i < Data::LASTTYPE; ++i) { // Walk through all data types
      Data::tTimeKeys a(data.timeKeys(*it, (Data::Type) i));
      Data::tTimeKeys::size_type n(pd(a));
      if (n) { // Something to prune
        size_t nDropped(0);
        for (Data::tTimeKeys::const_iterator jt(a.begin()), jet(a.end()); jt != jet; ++jt) {
          if (jt->second) {
            k.insert(jt->second);
            ++nDropped;
          }
        }
        std::cout << "Dropping " << nDropped << " rows of " << a.size() << " from " 
                  << data.source().key2name(*it) << " for type " << i << std::endl;
      } 
    }
    if (!data.nRows(*it)) {
	    std::cout << data.source().key2name(*it) << " is empty" << std::endl; 
    }
  }

  if (!k.empty()) {
    std::cout << "Dropped " << k.size() << " rows" << std::endl;
    data.dropRows(k);
    data.checkPoint();
  }
}
コード例 #10
0
ファイル: EVUtil.cpp プロジェクト: douzsh/douzsh
void EVUtil::CompactMDB( CString szSrc, CString szDst )
{
	try   
	{   
		CString csSourceConnection;   
		CString csDestConnection;   

		CoInitialize(0);   

		csSourceConnection.Format("Provider=Microsoft.Jet.OLEDB.4.0;Data Source=%s;",szSrc);   
		csDestConnection.Format("Provider=Microsoft.Jet.OLEDB.4.0;Data Source=%s;",szDst);   

		JRO::IJetEnginePtr jet(__uuidof(JRO::JetEngine));   

		jet->CompactDatabase(csSourceConnection.AllocSysString(),csDestConnection.AllocSysString());  
		CoUninitialize();
	}   
	catch(_com_error &e)   
	{   
		CString csError;   
		csError =(LPCTSTR) e.Description();   
		//MessageBox(csError,"Error Info",MB_ICONEXCLAMATION);
	}   
}
コード例 #11
0
void minivalidator::analyze(size_t childid /* this info can be used for printouts */){

        d_ana::dBranchHandler<Electron> elecs(tree(),"Electron");
        d_ana::dBranchHandler<HepMCEvent>  event(tree(),"Event");
        d_ana::dBranchHandler<GenParticle> genpart(tree(),"Particle");
        d_ana::dBranchHandler<Jet>         genjet(tree(),"GenJet");
        d_ana::dBranchHandler<Jet>         jet(tree(),"JetPUPPI");
        d_ana::dBranchHandler<Jet>         taujet(tree(),"Jet");
        d_ana::dBranchHandler<Muon>        muontight(tree(),"MuonTight");
        d_ana::dBranchHandler<Photon>      photon(tree(),"Photon");
        d_ana::dBranchHandler<MissingET>   met(tree(),"MissingET");
        d_ana::dBranchHandler<MissingET>   puppimet(tree(),"PuppiMissingET");
        d_ana::dBranchHandler<MissingET>   genpumet(tree(),"GenPileUpMissingET");
        d_ana::dBranchHandler<MissingET>   genmet(tree(),"GenMissingET");


        size_t nevents=tree()->entries();
        if(isTestMode())
                nevents/=100;


        //create output
        TString chilidstr="";
        chilidstr+=childid;
        TFile * outfile= new TFile(getOutDir()+"/p2val_"+(TString)getLegendName()+"_"+chilidstr+".root","RECREATE");
        TDirectory *counterdir = outfile->mkdir("weightCounter");
        counterdir->cd();
        TH1F * h_event_weight = new TH1F("Event_weight","Event_weight",1,0,1);

        outfile->cd();
        TDirectory *muondir = outfile->mkdir("muonTight");
        muondir->cd();
        TH1F * h_muontight_all_pt = new TH1F("h_muontight_all_pt","Muon PT",200,0,200);
        TH1F * h_muontight_all_eta = new TH1F("h_muontight_all_eta","Muon eta",200,-5,5);
        TH1F * h_muontight_all_phi = new TH1F("h_muontight_all_phi","Muon phi",200,-3.5,3.5);
        TH1F * h_muontight_all_tof = new TH1F("h_muontight_all_tof","Muon tof",200,0,10);
        TH1F * h_muontight_all_charge = new TH1F("h_muontight_all_charge","Muon charge",2,-1,1);
        TH1F * h_muontight_all_IsolationVar = new TH1F("h_muontight_all_IsolationVar","Muon IsolationVar",100,0,20);
        TH1F * h_muontight_all_IsolationVarRhoCorr = new TH1F("h_muontight_all_IsolationVarRhoCorr","Muon IsolationVarRhoCorr",100,0,20);
        TH1F * h_muontight_all_SumPtCharged = new TH1F("h_muontight_all_SumPtCharged","Muon SumPtCharged",100,0,20);
        TH1F * h_muontight_all_SumPtNeutral = new TH1F("h_muontight_all_SumPtNeutral","Muon SumPtNeutral",100,0,20);
        TH1F * h_muontight_all_SumPtChargedPU = new TH1F("h_muontight_all_SumPtChargedPU","Muon SumPtChargedPU",100,0,20);
        TH1F * h_muontight_all_SumPt = new TH1F("h_muontight_all_SumPt","Muon SumPt",100,0,20);

        TH1F * h_muontight_iso_pt = new TH1F("h_muontight_iso_pt","Muon PT",200,0,200);
        TH1F * h_muontight_iso_eta = new TH1F("h_muontight_iso_eta","Muon eta",200,-5,5);
        TH1F * h_muontight_iso_phi = new TH1F("h_muontight_iso_phi","Muon phi",200,-3.5,3.5);

        TH2F * h_muontight_all_IsolationVarRhoCorr_pt = new TH2F ("h_muontight_all_IsolationVarRhoCorr_pt","",200,0,20,200,0,20);

        outfile->cd();
        TDirectory *zmmdir = outfile->mkdir("zmm");
        zmmdir->cd();
        TH1F * h_zmm_m1_pt = new TH1F("h_zmm_m1_pt","Muon PT 1",200,0,200);
        TH1F * h_zmm_m2_pt = new TH1F("h_zmm_m2_pt","Muon PT 2",200,0,200);
        TH1F * h_zmm_mass  = new TH1F("h_zmm_mass","ZMM mass",200,60,120);
        TH1F * h_zmm_met_pt = new TH1F("h_zmm_met_pt","MET ZMM sel",200,0,200);
        TH1F * h_zmm_puppimet_pt = new TH1F("h_zmm_puppimet_pt","MET no sel",200,0,200);
        TH1F * h_zmm_genpumet_pt = new TH1F("h_zmm_genpumet_pt","MET no sel",200,0,200);
        TH1F * h_zmm_genmet_pt = new TH1F("h_zmm_genmet_pt","MET no sel",200,0,200);

        TDirectory *metdir = outfile->mkdir("met");
        metdir->cd();
        TH1F * h_met_pt = new TH1F("h_met_pt","MET no sel",200,0,200);
        TH1F * h_puppimet_pt = new TH1F("h_puppimet_pt","MET no sel",200,0,200);
        TH1F * h_genpumet_pt = new TH1F("h_genpumet_pt","MET no sel",200,0,200);
        TH1F * h_genmet_pt = new TH1F("h_genmet_pt","MET no sel",200,0,200);

        //load effective corrections for delphes samples vs fullSim
        scaleFactors
                tightelecsf,medelecsf,looseelecsf,
                tightmuonsf,loosemuonsf,
                jetsf,
                tightphotonsf,loosephotonsf,
                metsf;

        TString basepath=getenv("CMSSW_BASE");
        basepath+="/src/PhaseTwoAnalysis/delphesInterface/ntupler/data/";

        tightelecsf.loadTH2D  (basepath+"ElectronTight_PTEta.root","FullSimOverDelphes");
        medelecsf.loadTH2D    (basepath+"ElectronMedium_PTEta.root","FullSimOverDelphes");
        //looseelecsf.loadTH2D  (cmsswbase+"bla.root","histo");
        //
        tightmuonsf.loadTH2D  (basepath+"MuonTight_PTEta.root","FullSimOverDelphes");
        //loosemuonsf.loadTH2D  (cmsswbase+"bla.root","histo");
        //
        //jetsf.loadTH2D        (cmsswbase+"bla.root","histo");
        //
        tightphotonsf.loadTH2D(basepath+"PhotonTight_PTEta.root","FullSimOverDelphes");
        //loosephotonsf.loadTH2D(cmsswbase+"bla.root","histo");
        //
        //metsf.loadTH2D        (cmsswbase+"bla.root","histo");

        for(size_t eventno=0;eventno<nevents;eventno++){
                /*
                 * The following two lines report the status and set the event link
                 * Do not remove!
                 */
                reportStatus(eventno,nevents);
                tree()->setEntry(eventno);

                if(event.size()<1)continue;

                h_event_weight->Fill(0.,(double)event.at(0)->Weight);

                // No selection
                h_met_pt->Fill(met.at(0)->MET);
                h_puppimet_pt->Fill(puppimet.at(0)->MET);
                h_genpumet_pt->Fill(genpumet.at(0)->MET);
                h_genmet_pt->Fill(genmet.at(0)->MET);

                // Playing at genlevel



                // Lets look for muons  
                Double_t maxpt1=0, maxpt2=0;
                size_t index1=0, index2=0;
                size_t ngoodmuons=0;

                for(size_t i=0;i<muontight.size();i++){
                        h_muontight_all_pt->Fill(muontight.at(i)->PT);
                        h_muontight_all_eta->Fill(muontight.at(i)->Eta);
                        h_muontight_all_phi->Fill(muontight.at(i)->Phi);
                        h_muontight_all_charge->Fill(muontight.at(i)->Charge);
                        h_muontight_all_tof->Fill(muontight.at(i)->T);
                        h_muontight_all_IsolationVar->Fill(muontight.at(i)->IsolationVar);
                        h_muontight_all_IsolationVarRhoCorr->Fill(muontight.at(i)->IsolationVarRhoCorr);
                        h_muontight_all_SumPtCharged->Fill(muontight.at(i)->SumPtCharged);
                        h_muontight_all_SumPtNeutral->Fill(muontight.at(i)->SumPtNeutral);
                        h_muontight_all_SumPtChargedPU->Fill(muontight.at(i)->SumPtChargedPU);
                        h_muontight_all_SumPt->Fill(muontight.at(i)->SumPt);
                  
                        h_muontight_all_IsolationVarRhoCorr_pt ->Fill(muontight.at(i)->IsolationVar,muontight.at(i)->PT);

                        if(muontight.at(i)->IsolationVarRhoCorr<0.1) { // this is just a guess  
                                h_muontight_iso_pt->Fill(muontight.at(i)->PT);
                                h_muontight_iso_eta->Fill(muontight.at(i)->Eta);
                                h_muontight_iso_phi->Fill(muontight.at(i)->Phi);                

                                if(muontight.at(i)->PT>maxpt1) { maxpt2=maxpt1; index2=index1; maxpt1=muontight.at(i)->PT; index1=i;}
                                else if (muontight.at(i)->PT>maxpt2) {maxpt2=muontight.at(i)->PT; index2=i;} 
                                ngoodmuons++;
                        }
                }
                if(ngoodmuons>=2) {
                        if( muontight.at(index1)->PT>20 && muontight.at(index2)->PT > 20 && 
                                        (muontight.at(index1)->Charge!=muontight.at(index2)->Charge) ) { 
                        h_zmm_m1_pt->Fill(muontight.at(index1)->PT);
                        h_zmm_m2_pt->Fill(muontight.at(index2)->PT);

                        TLorentzVector m1, m2;
                        m1.SetPtEtaPhiM(muontight.at(index1)->PT,muontight.at(index1)->Eta,muontight.at(index1)->Phi,0.105); 
                        m2.SetPtEtaPhiM(muontight.at(index2)->PT,muontight.at(index2)->Eta,muontight.at(index2)->Phi,0.105);

                        h_zmm_mass->Fill( (m1+m2).M() );

                        h_zmm_met_pt->Fill(met.at(0)->MET);
                        h_zmm_puppimet_pt->Fill(puppimet.at(0)->MET);
                        h_zmm_genpumet_pt->Fill(genpumet.at(0)->MET);
                        h_zmm_genmet_pt->Fill(genmet.at(0)->MET);


//                        Double_t mass2=2*muontight.at(index1)->PT*muontight.at(index2)->PT*( cosh(muontight.at(index1)->Eta-muontight.at(index2)->Eta) - cos(muontight.at(index1)->Phi-muontight.at(index2)->Phi) );
//                        std::cout<<muontight.at(index1)->PT<<"   "<<m1.Pt()<<std::endl;
//                        std::cout<<sqrt(mass2)<<"   "<<(m1+m2).M()<<std::endl;

                  }
                }
        }   



counterdir->cd();
h_event_weight->Write();

muondir->cd();
h_muontight_all_pt->Write();
h_muontight_all_eta    ->Write();
h_muontight_all_phi    ->Write();
h_muontight_all_charge ->Write();
h_muontight_all_tof    ->Write();
h_muontight_all_IsolationVar        ->Write();
h_muontight_all_IsolationVarRhoCorr ->Write();
h_muontight_all_SumPtCharged        ->Write();
h_muontight_all_SumPtNeutral        ->Write();
h_muontight_all_SumPtChargedPU      ->Write();
h_muontight_all_SumPt               ->Write();

h_muontight_all_IsolationVarRhoCorr_pt->Write();

h_muontight_iso_pt->Write();
h_muontight_iso_eta    ->Write();
h_muontight_iso_phi    ->Write();

zmmdir->cd();
h_zmm_m1_pt->Write();
h_zmm_m2_pt->Write();
h_zmm_mass->Write();
h_zmm_met_pt->Write();
h_zmm_puppimet_pt->Write();
h_zmm_genpumet_pt->Write();
h_zmm_genmet_pt->Write();

metdir->cd();
h_met_pt->Write();
h_puppimet_pt->Write();
h_genpumet_pt->Write();
h_genmet_pt->Write();

outfile->Close();
/*
 * Must be called in the end, takes care of thread-safe writeout and
 * call-back to the parent process
 */
processEndFunction();
}
コード例 #12
0
ファイル: isis_looper.C プロジェクト: rebecacern/OldVUB
void isis_looper::myLoop(int nsel, int mode, bool silent)
{

  char plotName[300];
  sprintf(plotName,"test");
  
  if (nsel == 0)                	{sprintf(plotName,"tt");}
  else if (nsel == 1)   		{sprintf(plotName,"twdr");}
  else if (nsel == -1)   		{sprintf(plotName,"twds");}
  else if (nsel == 2)   		{sprintf(plotName,"zjets");}
  else if (nsel == 3)   		{sprintf(plotName,"di");}
  else if (nsel == 4)			{sprintf(plotName, "st");}
  else if (nsel == 5)   		{sprintf(plotName,"wjets");}
  else if (nsel == 6)   		{sprintf(plotName,"qcd_mu");}
  else if (nsel == 7)                	{sprintf(plotName,"others");}
  
  else if (nsel == 555)                	{sprintf(plotName,"mc");}
  
  else if (nsel == 666)                	{sprintf(plotName,"data");}
    
  else if (nsel == -10)                   {sprintf(plotName,"tt");}
  else if (nsel ==  10)                   {sprintf(plotName,"tt");}
  
  bool nosf = false;
  
  
  char newRootFile[300];
  double lumi = luminosity; 
  if (mode == 0 )        lumi = 4399; 
  else if ( mode == 1)   lumi = 1000; // to check 
  else if ( mode == 2)   lumi = 5103.58; // to check 
  sprintf(newRootFile,"results/an_%dpb_%d.root", (int)lumi, mode);
  
   if(nsel == -10){
  sprintf(newRootFile,"results/JERsysDown_an_%dpb_%d.root", (int)lumi, mode);
  }else if(nsel == 10 ){
   sprintf(newRootFile,"results/JERsysUp_an_%dpb_%d.root", (int)lumi, mode);
  }
 
  TFile f_var(newRootFile, "UPDATE");
  
  if(!silent){
    std::cout << "[Info:] results root file " << newRootFile << std::endl;
  }
  
  
  //////////
  char title[300];
  sprintf(title,"cuts_%s",plotName);
  TH1F* histo = new TH1F( title, " ", 10,  0, 10 );
  histo->Sumw2();
  
  sprintf(title,"met_high_%s",plotName);
  TH1F* histo_met_high = new TH1F( title, " ", 100,  0, 200 );
  histo_met_high->Sumw2();
  
  sprintf(title,"met_low_%s",plotName);
  TH1F* histo_met_low = new TH1F( title, " ", 100,  0, 200 );
  histo_met_low->Sumw2();
  
  sprintf(title,"promet_%s",plotName);
  TH1F* histo_promet = new TH1F( title, " ", 100,  0, 200 );
  histo_promet->Sumw2();
  
  sprintf(title,"met_cut_%s",plotName);
  TH1F* histo_met_cut = new TH1F( title, " ", 100,  0, 200 );
  histo_met_cut->Sumw2();
  
  sprintf(title,"met_bt_%s",plotName);
  TH1F* histo_met_bt = new TH1F( title, " ", 100,  0, 200 );
  histo_met_bt->Sumw2();
  
  sprintf(title,"mll_after_%s",plotName);
  TH1F* histo_mll_after = new TH1F( title, " ", 100,  0, 200 );
  histo_mll_after->Sumw2();
  
  sprintf(title,"njets_cut_%s",plotName);
  TH1F* histo_njets_cut = new TH1F( title, " ", 10,  -0.5, 9.5 );
  histo_njets_cut->Sumw2();
  
  sprintf(title,"njetsbt_cut_%s",plotName);
  TH1F* histo_njetsbt_cut = new TH1F( title, " ", 10,   -0.5, 9.5 );
  histo_njetsbt_cut->Sumw2();
  
  sprintf(title,"njetsbt_high_%s",plotName);
  TH1F* histo_njetsbt_high = new TH1F( title, " ", 10,   -0.5, 9.5 );
  histo_njetsbt_high->Sumw2();
  
  sprintf(title,"njetsbt_low_%s",plotName);
  TH1F* histo_njetsbt_low = new TH1F( title, " ", 10,   -0.5, 9.5 );
  histo_njetsbt_low->Sumw2();
  
  sprintf(title,"njets_high_%s",plotName);
  TH1F* histo_njets_high = new TH1F( title, " ", 10,   -0.5, 9.5 );
  histo_njets_high->Sumw2();
  
  sprintf(title,"njets_low_%s",plotName);
  TH1F* histo_njets_low = new TH1F( title, " ", 10,   -0.5, 9.5 );
  histo_njets_low->Sumw2();
  
  sprintf(title,"ptsys_high_%s",plotName);
  TH1F* histo_ptsys_high = new TH1F( title, " ", 100,  0, 200 );
  histo_ptsys_high->Sumw2();
  
  sprintf(title,"ptsys_low_%s",plotName);
  TH1F* histo_ptsys_low = new TH1F( title, " ", 100,  0, 200 );
  histo_ptsys_low->Sumw2();
  
  sprintf(title,"ht_high_%s",plotName);
  TH1F* histo_ht_high = new TH1F( title, " ", 300,  0, 600 );
  histo_ht_high->Sumw2();
  
  sprintf(title,"ht_low_%s",plotName);
  TH1F* histo_ht_low = new TH1F( title, " ", 300,  0, 600 );
  histo_ht_low->Sumw2();
  
  sprintf(title,"ht_cut_%s",plotName);
  TH1F* histo_ht_cut = new TH1F( title, " ", 300,  0, 600 );
  histo_ht_cut->Sumw2();
  
  sprintf(title,"pt_max_%s",plotName);
  TH1F* histo_pt_max = new TH1F( title, " ", 100,  0, 200 );
  histo_pt_max->Sumw2();
  
  sprintf(title,"pt_min_%s",plotName);
  TH1F* histo_pt_min = new TH1F( title, " ", 100,  0, 200 );
  histo_pt_min->Sumw2();
  
  sprintf(title,"btagHE_%s",plotName);
  TH2F* histo_btagHE = new TH2F( title, " ", 300,  -200, 100, 100, -2, 7);
  histo_btagHE->Sumw2();
  
  sprintf(title,"btagHP_%s",plotName);
  TH2F* histo_btagHP = new TH2F( title, " ", 300,  -200, 100, 100, -2, 7);
  histo_btagHP->Sumw2();
  
  sprintf(title,"etalepton_%s",plotName);
  TH1F* histo_etalepton = new TH1F( title, " ", 101,  -3, 3);
  histo_etalepton->Sumw2();
  
  sprintf(title,"ht_bf_%s",plotName);
  TH1F* histo_ht_bf = new TH1F( title, " ", 300,  0, 600 );
  histo_ht_bf->Sumw2();
  
  sprintf(title,"ptsys_bf_%s",plotName);
  TH1F* histo_ptsys_bf = new TH1F( title, " ", 100,  0, 200 );
  histo_ptsys_bf->Sumw2();
  
  sprintf(title,"npu_%s",plotName);
  TH1F* histo_npu = new TH1F( title, " ", 30,   -0.5, 29.5 );
  histo_npu->Sumw2();
  
  
  /// Classic plotmaker plots
  sprintf(title,"met_%s",plotName);
  TH1F* histo_met = new TH1F( title, " ", 100,  0, 200 );
  histo_met->Sumw2();
  
  sprintf(title,"mll_%s",plotName);
  TH1F* histo_mll = new TH1F( title, " ", 100,  0, 200 );
  histo_mll->Sumw2();
  
  sprintf(title,"njets_%s",plotName);
  TH1F* histo_njets = new TH1F( title, " ", 10,  0, 10 );
  histo_njets->Sumw2();
  
  sprintf(title,"njetsbt_%s",plotName);
  TH1F* histo_njetsbt = new TH1F( title, " ", 10,  -0.5, 9.5 );
  histo_njetsbt->Sumw2();
  
  sprintf(title,"ptsys_%s",plotName);
  TH1F* histo_ptsys = new TH1F( title, " ", 100,  0, 200 );
  histo_ptsys->Sumw2();
  
  sprintf(title,"ht_%s",plotName);
  TH1F* histo_ht = new TH1F( title, " ", 300,  0, 600 );
  histo_ht->Sumw2();
  
  sprintf(title,"pt_leading_%s",plotName);
  TH1F* histo_pt_leading = new TH1F( title, " ", 100,  0, 200 );
  histo_pt_leading->Sumw2();
  
  
  sprintf(title,"eta_leading_%s",plotName);
  TH1F* histo_eta_leading = new TH1F( title, " ", 101,  -3, 3);
  histo_eta_leading->Sumw2();
  
  sprintf(title,"nvertex_%s",plotName);
  TH1F* histo_nvertex = new TH1F( title, " ", 70,   -0.5, 69.5 );
  histo_nvertex->Sumw2();
 
  
  // 1 jet level
  /// Classic plotmaker plots
  sprintf(title,"met_1j_%s",plotName);
  TH1F* histo_met_1j = new TH1F( title, " ", 100,  0, 200 );
  histo_met_1j->Sumw2();
  
  sprintf(title,"mll_1j_%s",plotName);
  TH1F* histo_mll_1j = new TH1F( title, " ", 100,  0, 200 );
  histo_mll_1j->Sumw2();
  
  sprintf(title,"ptsys_1j_%s",plotName);
  TH1F* histo_ptsys_1j = new TH1F( title, " ", 100,  0, 200 );
  histo_ptsys_1j->Sumw2();
  
  sprintf(title,"ht_1j_%s",plotName);
  TH1F* histo_ht_1j = new TH1F( title, " ", 300,  0, 600 );
  histo_ht_1j->Sumw2();
  
  sprintf(title,"pt_leading_1j_%s",plotName);
  TH1F* histo_pt_leading_1j = new TH1F( title, " ", 100,  0, 200 );
  histo_pt_leading_1j->Sumw2();
  
  sprintf(title,"nvertex_1j_%s",plotName);
  TH1F* histo_nvertex_1j = new TH1F( title, " ", 30,   -0.5, 29.5 );
  histo_nvertex_1j->Sumw2();
  
  // 1 jet level
  /// Classic plotmaker plots
  sprintf(title,"met_1j1t_%s",plotName);
  TH1F* histo_met_1j1t = new TH1F( title, " ", 100,  0, 200 );
  histo_met_1j1t->Sumw2();
  
  sprintf(title,"mll_1j1t_%s",plotName);
  TH1F* histo_mll_1j1t = new TH1F( title, " ", 100,  0, 200 );
  histo_mll_1j1t->Sumw2();
  
  sprintf(title,"ptsys_1j1t_%s",plotName);
  TH1F* histo_ptsys_1j1t = new TH1F( title, " ", 100,  0, 200 );
  histo_ptsys_1j1t->Sumw2();
  
  sprintf(title,"ht_1j1t_%s",plotName);
  TH1F* histo_ht_1j1t = new TH1F( title, " ", 300,  0, 600 );
  histo_ht_1j1t->Sumw2();
  
  sprintf(title,"pt_leading_1j1t_%s",plotName);
  TH1F* histo_pt_leading_1j1t = new TH1F( title, " ", 100,  0, 200 );
  histo_pt_leading_1j1t->Sumw2();
  
  sprintf(title,"nvertex_1j1t_%s",plotName);
  TH1F* histo_nvertex_1j1t = new TH1F( title, " ", 30,   -0.5, 29.5 );
  histo_nvertex_1j1t->Sumw2();
  
  
  // 2j1t
  /// Classic plotmaker plots
  sprintf(title,"met_2j1t_%s",plotName);
  TH1F* histo_met_2j1t = new TH1F( title, " ", 100,  0, 200 );
  histo_met_2j1t->Sumw2();
  
  sprintf(title,"mll_2j1t_%s",plotName);
  TH1F* histo_mll_2j1t = new TH1F( title, " ", 100,  0, 200 );
  histo_mll_2j1t->Sumw2();
  
  sprintf(title,"ptsys_2j1t_%s",plotName);
  TH1F* histo_ptsys_2j1t = new TH1F( title, " ", 100,  0, 200 );
  histo_ptsys_2j1t->Sumw2();
  
  sprintf(title,"ht_2j1t_%s",plotName);
  TH1F* histo_ht_2j1t = new TH1F( title, " ", 300,  0, 600 );
  histo_ht_2j1t->Sumw2();
  
  sprintf(title,"pt_leading_2j1t_%s",plotName);
  TH1F* histo_pt_leading_2j1t = new TH1F( title, " ", 100,  0, 200 );
  histo_pt_leading_2j1t->Sumw2();
  
  sprintf(title,"nvertex_2j1t_%s",plotName);
  TH1F* histo_nvertex_2j1t = new TH1F( title, " ", 30,   -0.5, 29.5 );
  histo_nvertex_2j1t->Sumw2();
  
  
  // 2j2t
  /// Classic plotmaker plots
  sprintf(title,"met_2j2t_%s",plotName);
  TH1F* histo_met_2j2t = new TH1F( title, " ", 100,  0, 200 );
  histo_met_2j2t->Sumw2();
  
  sprintf(title,"mll_2j2t_%s",plotName);
  TH1F* histo_mll_2j2t = new TH1F( title, " ", 100,  0, 200 );
  histo_mll_2j2t->Sumw2();
  
  sprintf(title,"ptsys_2j2t_%s",plotName);
  TH1F* histo_ptsys_2j2t = new TH1F( title, " ", 100,  0, 200 );
  histo_ptsys_2j2t->Sumw2();
  
  sprintf(title,"ht_2j2t_%s",plotName);
  TH1F* histo_ht_2j2t = new TH1F( title, " ", 300,  0, 600 );
  histo_ht_2j2t->Sumw2();
  
  sprintf(title,"pt_leading_2j2t_%s",plotName);
  TH1F* histo_pt_leading_2j2t = new TH1F( title, " ", 100,  0, 200 );
  histo_pt_leading_2j2t->Sumw2();
  
  sprintf(title,"nvertex_2j2t_%s",plotName);
  TH1F* histo_nvertex_2j2t = new TH1F( title, " ", 30,   -0.5, 29.5 );
  histo_nvertex_2j2t->Sumw2();

  
  // all regions
  sprintf(title,"R_%s",plotName);
  TH1F* histo_R = new TH1F( title, " ", 40,  0, 40 );
  histo_R->Sumw2();
  
  
  // checking pu reweighting
  sprintf(title,"nvertex_final_%s",plotName);
  TH1F* histo_nvertex_final = new TH1F( title, " ", 70,   -0.5, 69.5 );
  histo_nvertex_final->Sumw2();
  
  sprintf(title,"nvertex_final_3D_%s",plotName);
  TH1F* histo_nvertex_final_3D = new TH1F( title, " ", 70,   -0.5, 69.5 );
  histo_nvertex_final_3D->Sumw2();
  
  sprintf(title,"nvertex_final_purw_%s",plotName);
  TH1F* histo_nvertex_final_purw = new TH1F( title, " ", 70,   -0.5, 69.5 );
  histo_nvertex_final_purw->Sumw2();
  


  sprintf(title,"nvertex_2lep_%s",plotName);
  TH1F* histo_nvertex_2lep = new TH1F( title, " ", 70,   -0.5, 69.5 );
  histo_nvertex_2lep->Sumw2();
//<<<<<<< isis_looper.C
  
  //_________________________________________________________________________________
  //added by Isis
  
  // -- Leading jet --- 
    sprintf(title,"eta_jet_%s",plotName);
  TH1F* histo_eta_jet = new TH1F( title, " ", 50,-5, 5 );  //#bins - begin - end
  histo_eta_jet->Sumw2();
  
 
     sprintf(title,"eta_jet_110_%s",plotName);
  TH1F* histo_eta_jet_110 = new TH1F( title, " ", 50,-5, 5 );  //#bins - begin - end
  histo_eta_jet_110->Sumw2();
  
      sprintf(title,"eta_jet_90_%s",plotName);
  TH1F* histo_eta_jet_90 = new TH1F( title, " ", 50,-5, 5 );  //#bins - begin - end
  histo_eta_jet_90->Sumw2();
  
  
      sprintf(title,"eta_jet_70_%s",plotName);
  TH1F* histo_eta_jet_70 = new TH1F( title, " ", 50,-5, 5 );  //#bins - begin - end
  histo_eta_jet_70->Sumw2();
  
  
      sprintf(title,"eta_jet_50_%s",plotName);
  TH1F* histo_eta_jet_50 = new TH1F( title, " ", 50,-5, 5 );  //#bins - begin - end
  histo_eta_jet_50->Sumw2();
  
      sprintf(title,"eta_jet_30_%s",plotName);
  TH1F* histo_eta_jet_30 = new TH1F( title, " ", 50,-5, 5 );  //#bins - begin - end
  histo_eta_jet_30->Sumw2();
 
 
   // -- Second Leading jet --- 
    sprintf(title,"eta_jet1_%s",plotName);
  TH1F* histo_eta_jet1 = new TH1F( title, " ", 50,-5, 5 );  //#bins - begin - end
  histo_eta_jet1->Sumw2();
  
 
     sprintf(title,"eta_jet1_110_%s",plotName);
  TH1F* histo_eta_jet1_110 = new TH1F( title, " ", 50,-5, 5 );  //#bins - begin - end
  histo_eta_jet1_110->Sumw2();
  
      sprintf(title,"eta_jet1_90_%s",plotName);
  TH1F* histo_eta_jet1_90 = new TH1F( title, " ", 50,-5, 5 );  //#bins - begin - end
  histo_eta_jet1_90->Sumw2();
  
  
      sprintf(title,"eta_jet1_70_%s",plotName);
  TH1F* histo_eta_jet1_70 = new TH1F( title, " ", 50,-5, 5 );  //#bins - begin - end
  histo_eta_jet1_70->Sumw2();
  
  
      sprintf(title,"eta_jet1_50_%s",plotName);
  TH1F* histo_eta_jet1_50 = new TH1F( title, " ", 50,-5, 5 );  //#bins - begin - end
  histo_eta_jet1_50->Sumw2();
  
      sprintf(title,"eta_jet1_30_%s",plotName);
  TH1F* histo_eta_jet1_30 = new TH1F( title, " ", 50,-5, 5 );  //#bins - begin - end
  histo_eta_jet1_30->Sumw2();
  
  // ---- Z/gamma controlregion 
 
    sprintf(title,"mll_zgamma_%s",plotName);
  TH1F* histo_mll_zgamma = new TH1F( title, " ", 50,  0, 200 );
  histo_mll_zgamma->Sumw2();
  
  
    sprintf(title,"met_zgamma_%s",plotName);
  TH1F* histo_met_zgamma= new TH1F( title, " ", 50,  0, 200 );
  histo_met_zgamma->Sumw2();
  
//=======
//>>>>>>> 1.1.2.3



  

//__________________________________________________ END HISTO DEF _________________________________________________________


  if (fChain == 0) return;
  
  Long64_t nentries = fChain->GetEntriesFast();
  
  Long64_t nbytes = 0, nb = 0;
  for (Long64_t jentry=0; jentry<nentries;jentry++) {
    
    
    Long64_t ientry = LoadTree(jentry);
    if (ientry < 0) break;
    nb = fChain->GetEntry(jentry);   nbytes += nb;
    
    
    if (lumi != lum && nsel != 666 && mode !=3){
      if (jentry == 0)std::cout << "[Warning:] This tree was made with a different luminosity (" << lum << ") than " << lumi << std::endl;
      //xlWeight*=(lumi/lum);
    }
    
  //  if(puweight > 5){ continue ;}
    
    if(ptLepton->size() != 2){
      std::cout << "[Warning:] Something is wrong, your Tree is not correctly filled" << std::endl;
      break;
    } else {
      histo->Fill(0.,xlWeight);
      histo_nvertex_2lep->Fill(nvertex,xlWeight);
      TLorentzVector lepton0(pxLepton->at(0),pyLepton->at(0), pzLepton->at(0), eLepton->at(0));
      TLorentzVector lepton1(pxLepton->at(1),pyLepton->at(1), pzLepton->at(1), eLepton->at(1)); 
      TLorentzVector pair = lepton0+lepton1;
      
      double phipairmet_t = 0;
      double pi_m = 3.1416/2;
      phipairmet_t = pi_m;
      
      TVector3 vmet(metPx, metPy, 0);
      
      double promet = metPt*sin(phipairmet_t);
      TVector3 m0(pxLepton->at(0),pyLepton->at(0), pzLepton->at(0));
      TVector3 m1(pxLepton->at(1),pyLepton->at(1), pzLepton->at(1)); 
      if (fabs(m0.DeltaPhi(vmet)) < phipairmet_t) phipairmet_t = fabs(m0.DeltaPhi(vmet));
      if (fabs(m1.DeltaPhi(vmet)) < phipairmet_t) phipairmet_t = fabs(m1.DeltaPhi(vmet));
      
      if (phipairmet_t == pi_m) promet = metPt;
      
      if (pair.M() > 20){
	histo->Fill(1, xlWeight);

	double SFval, SFerror;
	if ( nsel == 666 || nosf){
	  SFval = 1;
	  SFerror = 0;
	} else if (nsel == 0){
	  SFval = 0.95;
	  SFerror = 0.03;
	} else {
	  SFval = 0.97;
	  SFerror = 0.03;
	}
	
	
	int nJetsBT = 0;
	int nTightJetsBT = 0;
	int nJets = 0;
	bool bTagged = false;
	int iJetn[5]={-1, -1,-1,-1,-1};
	int iJet = -5;
	int iSF;
	double tempSF = SFval;
	
	int SFvalue = int(tempSF*100);
	
	for (unsigned int i =0; i < ptJet->size(); i ++){ 
	  TLorentzVector tempJet(pxJet->at(i),pyJet->at(i), pzJet->at(i), eJet->at(i));
	  if (ptJet->at(i) > 30 && TMath::Min(fabs(lepton0.DeltaR(tempJet)), fabs(lepton1.DeltaR(tempJet))) > 0.3) {
	    
	    iJetn[nJets] = i;
	    iJet = i;
	    nJets++;
	    
	    
	    if (btCSVBJet->at(i) > 0.679){
	      iSF = rand() % 100;
	      if (iSF < SFvalue ){
		bTagged = true;
		nJetsBT++;
		nTightJetsBT++;
	      } 
	    } 
	  } else if (btCSVBJet->at(i) > 0.679){
	    iSF = rand() % 100;
	    if (iSF < SFvalue ) nJetsBT++;
	  }  
	  
	}
	
	
        if(nJets){
	 TLorentzVector jet(pxJet->at(iJetn[0]),pyJet->at(iJetn[0]), pzJet->at(iJetn[0]), eJet->at(iJetn[0]));
	// TLorentzVector jet1(pxJet->at(iJetn[1]),pyJet->at(iJetn[1]), pzJet->at(iJetn[1]), eJet->at(iJetn[1])); //2e jet erbij nemen
	 histo_eta_jet->Fill(jet.Eta(),xlWeight);      
	 //histo_eta_jet1->Fill(jet1.Eta(),xlWeight);    // 2e jet in dezelfde plot steken , misschien beter om aparte plot te maken? 
	 
	 if( ptJet->at(iJet) > 110 ){
	   histo_eta_jet_110->Fill(jet.Eta(),xlWeight); 
	  // histo_eta_jet1_110->Fill(jet1.Eta(),xlWeight); 
	}
	 if (ptJet->at(iJet) > 90){
	   histo_eta_jet_90->Fill(jet.Eta(),xlWeight);
	 //  histo_eta_jet1_90->Fill(jet1.Eta(),xlWeight);  
	 }
	 if (ptJet->at(iJet) > 70){
	   histo_eta_jet_70->Fill(jet.Eta(),xlWeight);
	 //  histo_eta_jet1_70->Fill(jet1.Eta(),xlWeight);  
	 }
	 if(ptJet->at(iJet) > 50){
	  histo_eta_jet_50->Fill(jet.Eta(),xlWeight); 
	 // histo_eta_jet1_50->Fill(jet1.Eta(),xlWeight); 
	 }
	 if (ptJet->at(iJet) > 30){
	  histo_eta_jet_30->Fill(jet.Eta(),xlWeight);
	 // histo_eta_jet1_30->Fill(jet1.Eta(),xlWeight); 
	 }
	 
	
	}
	

	histo_pt_max->Fill(TMath::Max(lepton0.Pt(), lepton1.Pt()), xlWeight);
	histo_pt_min->Fill(TMath::Min(lepton0.Pt(), lepton1.Pt()), xlWeight);
	histo_njets->Fill(nJets,  xlWeight);
	histo_njetsbt->Fill(nJetsBT,  xlWeight);
	histo_mll->Fill(pair.M(),  xlWeight);
	histo_met->Fill(metPt,  xlWeight);
	histo_promet->Fill(promet, xlWeight);
	

	if (nvertex > 5){
	  histo_met_high->Fill(metPt,  xlWeight);
	  histo_njets_high->Fill(nJets,  xlWeight);
	  histo_njetsbt_high->Fill(nJetsBT,  xlWeight);
	} else {
	  histo_met_low->Fill(metPt,  xlWeight);
	  histo_njets_low->Fill(nJets,  xlWeight);
	  histo_njetsbt_low->Fill(nJetsBT,  xlWeight);  
	}
	
	if (nJets) histo_pt_leading->Fill(ptJet->at(0), xlWeight);
	
	if (nJets){
	  TLorentzVector jet_aux(pxJet->at(0),pyJet->at(0), pzJet->at(0), eJet->at(0));
	  histo_eta_leading->Fill(jet_aux.Eta(), xlWeight);
	}
	
	if (nJets == 1){
	  histo_etalepton->Fill(lepton0.Eta(), xlWeight);
	  TLorentzVector jet(pxJet->at(iJet),pyJet->at(iJet), pzJet->at(iJet), eJet->at(iJet));
	   
	  double ptSysPx1 = lepton0.Px() + lepton1.Px() + jet.Px() + metPx;
	  double ptSysPy1 = lepton0.Py() + lepton1.Py() + jet.Py() + metPy;
	  double ptSystem1 = sqrt(ptSysPx1*ptSysPx1 + ptSysPy1*ptSysPy1);
	  double ht1 = lepton0.Pt() + lepton1.Pt() + jet.Pt() + metPt; 
	  histo_ptsys_bf->Fill(ptSystem1, xlWeight);
	  histo_ht_bf->Fill(ht1, xlWeight);
	}
	bool invMass = false;
	if      (mode == 0) invMass = true;
	else if (mode == 1  && (pair.M() > invMax || pair.M() < invMin)) invMass = true;
	else if (mode == 2 && (pair.M() > invMax || pair.M() < invMin)) invMass = true;
	
	//____________________________
        //Z/gamma control region
        
	//if (pair.M() > 81 || pair.M() < 101)
	if(!invMass || (mode == 0 && (pair.M() > 81 || pair.M() < 101) )) 
	{	  
	         
		  histo_mll_zgamma->Fill(pair.M(),  xlWeight);
	          histo_met_zgamma->Fill(metPt,  xlWeight);
	          
	}	 

	//______________________________________


	if (invMass){
	  histo->Fill(2, xlWeight);
	  histo_mll_after->Fill(pair.M(),  xlWeight);
	  histo_met_cut->Fill(metPt,  xlWeight);
	  if (metPt >= metCut || mode ==0){
	   
	    histo->Fill(3, xlWeight);
	    histo_njets_cut->Fill(nJets, xlWeight);
	    if (nJets == 1){
	      histo->Fill(4, xlWeight);
	      histo_njetsbt_cut->Fill(nJetsBT, xlWeight);
	      TLorentzVector jet(pxJet->at(iJet),pyJet->at(iJet), pzJet->at(iJet), eJet->at(iJet));
		
	      double ptSysPx = lepton0.Px() + lepton1.Px() + jet.Px() + metPx;
	      double ptSysPy = lepton0.Py() + lepton1.Py() + jet.Py() + metPy;
	      double ptSystem = sqrt(ptSysPx*ptSysPx + ptSysPy*ptSysPy);
	      double ht = lepton0.Pt() + lepton1.Pt() + jet.Pt() + metPt; 
	      
	      histo_mll_1j->Fill(pair.M(),  xlWeight);
	      histo_met_1j->Fill(metPt,  xlWeight);
	      histo_ptsys_1j->Fill(ptSystem, xlWeight);
	      histo_ht_1j->Fill(ht, xlWeight);
	      histo_pt_leading_1j->Fill(jet.Pt(), xlWeight);
	      
	      
	      if (nJets == 1 && nTightJetsBT == 1 && bTagged && nJetsBT == 1){
		histo->Fill(5, xlWeight);
		
	      
	        histo_mll_1j1t->Fill(pair.M(),  xlWeight);
	        histo_met_1j1t->Fill(metPt,  xlWeight);
	        histo_ptsys_1j1t->Fill(ptSystem, xlWeight);
	        histo_ht_1j1t->Fill(ht, xlWeight);
	        histo_pt_leading_1j1t->Fill(jet.Pt(), xlWeight);
	      
		histo_ptsys->Fill(ptSystem, xlWeight);
		histo_ht->Fill(ht, xlWeight);
		
		histo_met_bt->Fill(metPt, xlWeight);
		
		histo_nvertex->Fill(nvertex, xlWeight);
		histo_npu->Fill(npu, xlWeight);
		
		if (nvertex > 5) {
		  histo_ptsys_high->Fill(ptSystem, xlWeight);
		  histo_ht_high->Fill(ht, xlWeight);
		} else {
		  histo_ptsys_low->Fill(ptSystem, xlWeight);
		  histo_ht_low->Fill(ht, xlWeight);
		  
		}
		
		if (ht > htMin || mode !=0){
		  histo->Fill(6, xlWeight);
		  histo_ht_cut->Fill(ht, xlWeight);
		  
		  //Example to access the pu reweighting!
		  histo_nvertex_final->Fill(nvertex, rawWeight);
		  histo_nvertex_final_3D->Fill(nvertex, rawWeight*puweight3D);
		  histo_nvertex_final_purw->Fill(nvertex, rawWeight*puweight);
		  
		}
	      }
	    }
	  }
	  
	  
	  //Filling of all region from here
	  if (metPt >= metCut || mode ==0){
	
	    if (nJets != 0){
	      
	      TLorentzVector jet(pxJet->at(iJet),pyJet->at(iJet), pzJet->at(iJet), eJet->at(iJet));
	      
	      double ptSysPx = lepton0.Px() + lepton1.Px() + jet.Px() + metPx;
	      double ptSysPy = lepton0.Py() + lepton1.Py() + jet.Py() + metPy;
	      double ptSystem = sqrt(ptSysPx*ptSysPx + ptSysPy*ptSysPy);
	      double ht = lepton0.Pt() + lepton1.Pt() + jet.Pt() + metPt; 
	      
	      if (nJets == 2 && nTightJetsBT == 1 && nJetsBT == 1) {
	        histo_mll_2j1t->Fill(pair.M(),  xlWeight);
	        histo_met_2j1t->Fill(metPt,  xlWeight);
	        histo_ptsys_2j1t->Fill(ptSystem, xlWeight);
	        histo_ht_2j1t->Fill(ht, xlWeight);
	        histo_pt_leading_2j1t->Fill(jet.Pt(), xlWeight);
	      } else if (nJets == 2 && nTightJetsBT == 2 && nJetsBT == 2)  {
	        histo_mll_2j2t->Fill(pair.M(),  xlWeight);
	        histo_met_2j2t->Fill(metPt,  xlWeight);
	        histo_ptsys_2j2t->Fill(ptSystem, xlWeight);
	        histo_ht_2j2t->Fill(ht, xlWeight);
	        histo_pt_leading_2j2t->Fill(jet.Pt(), xlWeight);
	      }
	      
	      
	   
		  
	      //All possible regions
	      if (nJets == 1 && nTightJetsBT == 1 && bTagged && nJetsBT == 1 && ptSystem <= ptsysCut && (ht > htMin || mode !=0))histo_R->Fill(1, xlWeight); //signal
	      if (nJets == 1 && nTightJetsBT == 2)  histo_R->Fill(2, xlWeight);
	      if (nJets == 1 && nTightJetsBT > 0)  histo_R->Fill(3, xlWeight);
	      if (nJets == 1 && nTightJetsBT > 1)  histo_R->Fill(4, xlWeight);
	      if (nJets == 2 && nTightJetsBT == 0)  histo_R->Fill(5, xlWeight);
	      if (nJets == 2 && nTightJetsBT == 1)  histo_R->Fill(6, xlWeight); //CR1 no ht no ptsys
	      if (nJets == 2 && nTightJetsBT == 2)  histo_R->Fill(7, xlWeight); //CR2 no ht no ptsys
	      if (nJets == 2 && nTightJetsBT > 0)  histo_R->Fill(8, xlWeight);
	      if (nJets == 2 && nTightJetsBT > 1)  histo_R->Fill(9, xlWeight);
	      if (nJets > 1 && nTightJetsBT == 0)  histo_R->Fill(10, xlWeight);
	      if (nJets > 1 && nTightJetsBT == 1)  histo_R->Fill(11, xlWeight);
	      if (nJets > 1 && nTightJetsBT == 2)  histo_R->Fill(12, xlWeight);
	      if (nJets > 1 && nTightJetsBT !=0 )  histo_R->Fill(13, xlWeight);
	      if (nJets > 1 && nTightJetsBT > 1 )  histo_R->Fill(14, xlWeight);
	      if (nJets == 3 && nTightJetsBT ==3 )  histo_R->Fill(15, xlWeight);
	      if (nJets == 1 && nTightJetsBT ==1 && bTagged && nJetsBT == 1)  histo_R->Fill(16, xlWeight);
	      if (nJets == 2 && nTightJetsBT == 1 && ptSystem <= ptsysCut && (ht > htMin || mode !=0))  histo_R->Fill(17, xlWeight); //CR 1 regular
	      if (nJets == 2 && nTightJetsBT == 2 && ptSystem <= ptsysCut && (ht > htMin || mode !=0))  histo_R->Fill(18, xlWeight); //CR 2 regular
	      if (nJets == 2 && nTightJetsBT == 1 && nJetsBT == 1 && ptSystem <= ptsysCut && (ht > htMin || mode !=0))  histo_R->Fill(19, xlWeight);
	      if (nJets == 2 && nTightJetsBT == 2 && nJetsBT == 2 && ptSystem <= ptsysCut && (ht > htMin || mode !=0))  histo_R->Fill(20, xlWeight);
	      if (nJets == 2 && nJetsBT == 1 && ptSystem <= ptsysCut && (ht > htMin || mode !=0))  histo_R->Fill(21, xlWeight); //CR 1 another way
	      if (nJets == 2 && nJetsBT == 2 && ptSystem <= ptsysCut && (ht > htMin || mode !=0))  histo_R->Fill(22, xlWeight); //CR 2 another way
	      if (nJets == 2 && nTightJetsBT == 1 && nJetsBT == 1)  histo_R->Fill(23, xlWeight); //CR1 no ht no ptsys tighter
	      if (nJets == 2 && nTightJetsBT == 2 && nJetsBT == 2)  histo_R->Fill(24, xlWeight); //CR2 no ht no ptsys tighter
	      if (nJets == 2 && nJetsBT == 1)  histo_R->Fill(25, xlWeight); //CR1 no ht no ptsys another flavor
	      if (nJets == 2 && nJetsBT == 2)  histo_R->Fill(26, xlWeight); //CR2 no ht no ptsys another flavor
	      if (nJets == 1 && nTightJetsBT == 1 && bTagged && nJetsBT == 1 && (ht > htMin || mode !=0))histo_R->Fill(27, xlWeight); //signal no ptsys
	      if (nJets == 1 && nTightJetsBT == 1 && bTagged && nJetsBT == 1 && ptSystem <= ptsysCut)histo_R->Fill(28, xlWeight); //signal no ht
	      if (nJets == 2 && nTightJetsBT == 1 &&  (ht > htMin || mode !=0))  histo_R->Fill(29, xlWeight); //CR 1 
	      if (nJets == 2 && nTightJetsBT == 2 &&  (ht > htMin || mode !=0))  histo_R->Fill(30, xlWeight); //CR 2 
				
	      
	    } //jets in the event
	  } //all CR
	  
	} // mll
      } //mll pre
    } // 2 leptons
  }// event loop.
  
  
  
  if (!silent){ 
    cout << "------------------------------------------" << endl;
    cout << "[Results:] " << plotName <<  endl;
    cout << "------------------------------------------" << endl;  
    for (int i = 2; i < 9; i++){
      if (i == 2) cout << " leptons: " <<  histo->GetBinContent(i) << " +/-  " <<  histo->GetBinError(i)  << endl;
      if (i == 3) cout << " inv. mass: " <<  histo->GetBinContent(i) << " +/-  " <<  histo->GetBinError(i)  << endl;
      if (i == 4) cout << " met: " <<  histo->GetBinContent(i) << " +/-  " <<  histo->GetBinError(i)  << endl;
      if (i == 5) cout << " jet: " <<  histo->GetBinContent(i) << " +/-  " <<  histo->GetBinError(i)  << endl;
      if (i == 6) cout << " jet_bt: " <<  histo->GetBinContent(i) << " +/-  " <<  histo->GetBinError(i)  << endl;
      if (i == 7) cout << " ht: " <<  histo->GetBinContent(i) << " +/-  " <<  histo->GetBinError(i)  << endl;
    }
    cout << "------------------------------------------" << endl; 
    cout << "[eta values:]" << plotName << endl;
    cout << "------------------------------------------" << endl; 
    for (int j =1 ; j<7; j++){
      if(j == 1) {
         double amount = 0; 
	 //double amounterror = 0; 
      
         for(int k = 0; k< 50; k++) {   
	     amount = amount + histo_eta_jet_30->GetBinContent(k); 
	  //   amounterror = sqrt(amounterror^2 + (histo_eta_jet_30->GetBinError(k))^2);
           //cout << "pt higher then 30: " << histo_eta_jet_30->GetBinContent(k) << " +/- " << histo_eta_jet_30->GetBinError(k) << endl; 
         }
	 
	 cout << "pt higher then 30: " << amount <<  endl;
      
      }
        if(j == 2) {
         double amount = 0; 
	 //double amounterror = 0; 
      
         for(int k = 0; k< 50; k++) {   
	     amount = amount + histo_eta_jet_50->GetBinContent(k); 
	  //   amounterror = sqrt(amounterror^2 + (histo_eta_jet_30->GetBinError(k))^2);
           //cout << "pt higher then 50: " << histo_eta_jet_30->GetBinContent(k) << " +/- " << histo_eta_jet_30->GetBinError(k) << endl; 
         }
	 
	 cout << "pt higher then 50: " << amount <<  endl;
      
      }
      
            if(j == 3) {
         double amount = 0; 
	 //double amounterror = 0; 
      
         for(int k = 0; k< 50; k++) {   
	     amount = amount + histo_eta_jet_70->GetBinContent(k); 
	  //   amounterror = sqrt(amounterror^2 + (histo_eta_jet_30->GetBinError(k))^2);
           //cout << "pt higher then 30: " << histo_eta_jet_30->GetBinContent(k) << " +/- " << histo_eta_jet_30->GetBinError(k) << endl; 
         }
	 
	 cout << "pt higher then 70: " << amount <<  endl;
      
      }
            if(j == 4) {
         double amount = 0; 
	 //double amounterror = 0; 
      
         for(int k = 0; k< 50; k++) {   
	     amount = amount + histo_eta_jet_70->GetBinContent(k); 
	  //   amounterror = sqrt(amounterror^2 + (histo_eta_jet_30->GetBinError(k))^2);
           //cout << "pt higher then 30: " << histo_eta_jet_30->GetBinContent(k) << " +/- " << histo_eta_jet_30->GetBinError(k) << endl; 
         }
	 
	 cout << "pt higher then 70: " << amount <<  endl;
      
      }
            if(j == 5) {
         double amount = 0; 
	 //double amounterror = 0; 
      
         for(int k = 0; k< 50; k++) {   
	     amount = amount + histo_eta_jet_90->GetBinContent(k); 
	  //   amounterror = sqrt(amounterror^2 + (histo_eta_jet_30->GetBinError(k))^2);
           //cout << "pt higher then 30: " << histo_eta_jet_30->GetBinContent(k) << " +/- " << histo_eta_jet_30->GetBinError(k) << endl; 
         }
	 
	 cout << "pt higher then 90: " << amount <<  endl;
      
      }
            if(j == 6) {
         double amount = 0; 
	 //double amounterror = 0; 
      
         for(int k = 0; k< 50; k++) {   
	     amount = amount + histo_eta_jet_110->GetBinContent(k); 
	  //   amounterror = sqrt(amounterror^2 + (histo_eta_jet_30->GetBinError(k))^2);
           //cout << "pt higher then 30: " << histo_eta_jet_30->GetBinContent(k) << " +/- " << histo_eta_jet_30->GetBinError(k) << endl; 
         }
	 
	 cout << "pt higher then 110: " << amount <<  endl;
      
      }
    
    }
    
    
    
    
  }
  f_var.Write();
  f_var.Close();
}
コード例 #13
0
ファイル: UserAnalysis.C プロジェクト: SimTools/physsim
//_________________________________________________________
void UserAnalysis()
{
  // Debug a particular event.
  
  Int_t eventToDebug = -1;
  if (jsf->GetEventNumber() == eventToDebug) {
  	gDEBUG = kTRUE;
        cerr << "------------------------------------------" << endl;
        cerr << "Event " << jsf->GetEventNumber();
        cerr << endl;
  } else {
  	gDEBUG = kFALSE;
  }

  Char_t msg[60];

  // Analysis starts here.
  
  Float_t selid = -0.5;
  hStat->Fill(++selid);
  if ( Ngoods == 0 ) strcpy(&cutName[(Int_t)selid][0],"No cut");

  // Get event buffer and make combined tracks accessible.

  JSFSIMDST     *sds     = (JSFSIMDST*)jsf->FindModule("JSFSIMDST");
  JSFSIMDSTBuf  *evt     = (JSFSIMDSTBuf*)sds->EventBuf();
  Int_t          ntrks   = evt->GetNLTKCLTracks(); 	// No. of tracks 
  TObjArray     *trks    = evt->GetLTKCLTracks(); 	// combined tracks
  
  ANL4DVector qsum;
  TObjArray tracks(500);
  tracks.SetOwner();
   
  // Select good tracks

  fNtracks = 0;
  for ( Int_t i = 0; i < ntrks; i++ ) {
    JSFLTKCLTrack *t = (JSFLTKCLTrack*)trks->UncheckedAt(i);
    if ( t->GetE() > xEtrack ) {
      ANL4DVector *qt = new ANL4DVector(t->GetPV());
      tracks.Add(qt); 		// track 4-momentum
      qsum += *qt;		// total 4-momentum
      fNtracks++;
    }				// *qt stays.
  }

  // Cut on No. of tracks.
  
  hNtracks->Fill(fNtracks);
  if ( fNtracks < xNtracks ) return;
  hStat->Fill(++selid);
  if ( Ngoods == 0 ) {
    sprintf(msg,"N_tracks > %g",xNtracks);
    strcpy(&cutName[(Int_t)selid][0],msg);
  }

  fEvis = qsum.E();		// E_vis
  fPt   = qsum.GetPt();		// P_t
  fPl   = qsum.Pz();		// P_l

  // Cut on Evis.

  hEvis->Fill(fEvis);
  if ( fEvis < xEvis ) return;
  hStat->Fill(++selid);
  if ( Ngoods == 0 ) {
    sprintf(msg,"E_vis > %g",xEvis);
    strcpy(&cutName[(Int_t)selid][0],msg);
  }
 
  // Cut on Pt.

  hPt->Fill(fPt);
  if ( fPt < xPt ) return;
  hStat->Fill(++selid);
  if ( Ngoods == 0 ) {
    sprintf(msg,"Pt > %g",xPt);
    strcpy(&cutName[(Int_t)selid][0],msg);
  }
 
  // Cut on Pl.

  if ( TMath::Abs(fPl) > xPl ) return;
  hStat->Fill(++selid);
  if ( Ngoods == 0 ) {
    sprintf(msg,"|Pl| <= %g",xPl);
    strcpy(&cutName[(Int_t)selid][0],msg);
  }

  // Find jets.

  fYcut = xYcut;
  ANLJadeEJetFinder jclust(fYcut);
  jclust.Initialize(tracks);
  jclust.FindJets();
  fYcut  = jclust.GetYcut();
  fNjets = jclust.GetNjets();

  // Cut on No. of jets.
    
  hNjets->Fill(fNjets);
  if ( fNjets < xNjets ) return;
  hStat->Fill(++selid);
  if ( Ngoods == 0 ) {
    sprintf(msg,"Njets >= %i for Ycut = %g",xNjets,xYcut);
    strcpy(&cutName[(Int_t)selid][0],msg);
  }
  
  // Now force the event to be xNjets.
  
  jclust.ForceNJets(xNjets);
  fNjets = jclust.GetNjets();
  fYcut  = jclust.GetYcut();

  // Make sure that No. of jets is xNjets.
    
  if ( fNjets != xNjets ) return;
  hStat->Fill(++selid);
  if ( Ngoods == 0 ) {
    sprintf(msg,"Njets = %i",xNjets);
    strcpy(&cutName[(Int_t)selid][0],msg);
  }
  
  // Loop over jets and decide Ejet_min and |cos(theta_j)|_max.
  
  TObjArray &jets = jclust.GetJets();	// jets is an array of ANLJet's
  TIter nextjet(&jets);			// and nextjet is an iterator for it
  ANLJet *jetp;
  Double_t ejetmin = 999999.;
  Double_t cosjmax = 0.;
  while ((jetp = (ANLJet *)nextjet())) {
    ANLJet &jet = *jetp;
    if (gDEBUG && kFALSE) jet.DebugPrint();
    Double_t ejet = jet().E();
    if (ejet < ejetmin) ejetmin = ejet;
    hEjet->Fill(ejet);			// Ejet
    Double_t cosj = jet.CosTheta();
    if (TMath::Abs(cosj) > TMath::Abs(cosjmax)) cosjmax = cosj;
    hCosjet->Fill(cosj);		// cos(theta_jet)
  }

  // Cut on Ejet_min.
  
  if ( ejetmin < xEjet ) return;
  hStat->Fill(++selid);
  if ( Ngoods == 0 ) {
    sprintf(msg,"Ejet > %g",xEjet);
    strcpy(&cutName[(Int_t)selid][0],msg);
  }

  // Cut on |cos(theta_j)|_max.
    
  if ( TMath::Abs(cosjmax) > xCosjet ) return;
  hStat->Fill(++selid);
  if ( Ngoods == 0 ) {
    sprintf(msg,"|cos(theta_j)| <= %g",xCosjet);
    strcpy(&cutName[(Int_t)selid][0],msg);
  }

  // Find W candidates in given mass windows.
  // Avoid using indices since there might be empty slots.
  
  TObjArray solutions(10);
  solutions.SetOwner();

  ANLPairCombiner w1candidates(jets,jets);
  ANLPairCombiner *w2candidp = 0;
  if (gDEBUG) {
    cerr << "------------------------------------------" << endl;
    cerr << "- w1candidates:" << endl;
    w1candidates.DebugPrint();
  }
  ANLPair *w1p, *w2p;
  while ((w1p = (ANLPair *)w1candidates())) {
    w2candidp   = 0;
    ANLPair &w1 = *w1p;
    Double_t w1mass = w1().GetMass();
    if (TMath::Abs(w1mass - kMassW) > xM2j) continue;	// w1 candidate found
    w1.LockChildren();					// now lock w1 daughters
    w2candidp = new ANLPairCombiner(w1candidates);	// w2 after w1
    ANLPairCombiner &w2candidates = *w2candidp;
    while ((w2p = (ANLPair *)w2candidates())) {
      ANLPair &w2 = *w2p;
      if (w2.IsLocked()) continue;			// skip if locked
      Double_t w2mass = w2().GetMass();
      if (TMath::Abs(w2mass - kMassW) > xM2j) continue;	// w2 candidate found
      Double_t chi2 = TMath::Power((w1mass - kMassW)/kSigmaMw,2.)
                    + TMath::Power((w2mass - kMassW)/kSigmaMw,2.);
      solutions.Add(new ANLPair(w1p,w2p,chi2));
      // hMw1Mw2->Fill(w1mass,w2mass,1.0);
    }
    if (w2candidp) delete w2candidp;
    w1.UnlockChildren();
  }
  
  // Cut on No. of solutions.

  if ( !solutions.GetEntries() ) return;
  hStat->Fill(++selid);
  if ( Ngoods == 0 ) {
    sprintf(msg,"|m_jj - m_W| <= %g",xM2j);
    strcpy(&cutName[(Int_t)selid][0],msg);
  }

  if (gDEBUG) {
    cerr << "------------------------------------------" << endl;
    cerr << "- w1candidates after 1:" << endl;
    w1candidates.DebugPrint();
  }

  // Cut on cos(theta_W).

  TIter nextsol(&solutions);
  ANLPair *sol;
  while ((sol = (ANLPair *)nextsol())) {
    ANL4DVector  &ww1 = *(ANL4DVector *)(*sol)[0];
    ANL4DVector  &ww2 = *(ANL4DVector *)(*sol)[1];
    Double_t ew1 = ww1.E();
    Double_t ew2 = ww2.E();
    hEw1Ew2->Fill(ew1,ew2,1.0);
    Double_t cosw1 = ww1.CosTheta();
    Double_t cosw2 = ww2.CosTheta();
    hCosw1Cosw2->Fill(cosw1,cosw2,1.0);
    if (TMath::Abs(cosw1) > xCosw || TMath::Abs(cosw2) > xCosw) {
      solutions.Remove(sol);
      delete sol;
    }
  }
  if ( !solutions.GetEntries() ) return;
  hStat->Fill(++selid);
  if ( Ngoods == 0 ) {
    sprintf(msg,"|cos(theta_w)| <= %g",xCosw);
    strcpy(&cutName[(Int_t)selid][0],msg);
  }

  if (gDEBUG) {
    cerr << "------------------------------------------" << endl;
    cerr << "- w1candidates after 2:" << endl;
    w1candidates.DebugPrint();
  }
  
  // Cut on Acop.

  nextsol.Reset();
  while ((sol = (ANLPair *)nextsol())) {
    ANL4DVector  &www1 = *(ANL4DVector *)(*sol)[0];
    ANL4DVector  &www2 = *(ANL4DVector *)(*sol)[1];
    Double_t acop = www1.Acop(www2);
    hAcop->Fill(acop);
    if (acop < xAcop) {
      solutions.Remove(sol);
      delete sol;
    }
  }
  if ( !solutions.GetEntries() ) return;
  hStat->Fill(++selid);
  if ( Ngoods == 0 ) {
    sprintf(msg,"Acop > %g",xAcop);
    strcpy(&cutName[(Int_t)selid][0],msg);
  }

  if (gDEBUG) {
    cerr << "------------------------------------------" << endl;
    cerr << "- w1candidates after 3:" << endl;
    w1candidates.DebugPrint();
  }

  // ------------------------
  //  End of event selection
  // ------------------------

  if ( Ngoods == 0 ) {
    selid++;
    sprintf(msg,"END");
    strcpy(&cutName[(Int_t)selid][0],msg);
  }
  Ngoods++;
 
  cerr << "------------------------------------------" << endl
       << "Event " << jsf->GetEventNumber() 
       << ": Number of solutions = " << solutions.GetEntries() << endl
       << "------------------------------------------" << endl;

  // Sort the solutions in the ascending order of chi2 vlues.
  
  solutions.Sort();

  // Hists and plots for selected events.

  if (gDEBUG && kFALSE) {
    Int_t nj = 0;
    nextjet.Reset();
    while ((jetp = (ANLJet *)nextjet())) {
       cerr << "------" << endl
            << "Jet " << ++nj << endl
            << "------" << endl;
       jetp->DebugPrint();
    }
  }

  hNsols->Fill(solutions.GetEntries());
  hEvisPl->Fill(fEvis,fPl,1.);
  
  nextsol.Reset();
  Int_t nsols = 0;
  while ((sol = (ANLPair *)nextsol())) {
    if ( nsols++ ) break;				// choose the best
    ANL4DVector  &wwww1 = *(ANL4DVector *)(*sol)[0];
    ANL4DVector  &wwww2 = *(ANL4DVector *)(*sol)[1];
    Double_t chi2   = sol->GetQuality();
    Double_t w1mass = wwww1.GetMass();
    Double_t w2mass = wwww2.GetMass();
          hChi2->Fill(chi2);
          hMw1Mw2->Fill(w1mass,w2mass,1.0);
  }
  
  return;
 }
コード例 #14
0
ファイル: UEJetArea.C プロジェクト: newbornking999/my_work
///
///________________________________________________________________________________
///
Bool_t
UEJetAreaFinder::find( TClonesArray& Input, vector<UEJetWithArea>& _jets )
{
  /// return if no four-vectors are provided
  if ( Input.GetSize() == 0 ) return kFALSE;

  /// prepare input
  std::vector<fastjet::PseudoJet> fjInputs;
  fjInputs.reserve ( Input.GetSize() );

  int iJet( 0 );
  for( int i(0); i < Input.GetSize(); ++i )
    {
      TLorentzVector *v = (TLorentzVector*)Input.At(i);

      if ( TMath::Abs(v->Eta()) > etaRegionInput ) continue;
      if ( v->Pt()              < ptThreshold    ) continue;

      fjInputs.push_back (fastjet::PseudoJet (v->Px(), v->Py(), v->Pz(), v->E()) );
      fjInputs.back().set_user_index(iJet);
      ++iJet;
    }

  /// return if no four-vectors in visible phase space
  if ( fjInputs.size() == 0 ) return kFALSE;
  
  /// print out info on current jet algorithm
  //   cout << endl;
  //   cout << mJetDefinition->description() << endl;
  //   cout << theAreaDefinition->description() << endl;

  /// return if active area is not chosen to be calculated
  if ( ! theAreaDefinition ) return kFALSE;

  //  cout << "fastjet::ClusterSequenceActiveArea* clusterSequence" << endl;
  
  fastjet::ClusterSequenceArea* clusterSequence
    = new fastjet::ClusterSequenceArea (fjInputs, *mJetDefinition, *theAreaDefinition );

  //  cout << "retrieve jets for selected mode" << endl;

  /// retrieve jets for selected mode
  double mJetPtMin( 1. );
  std::vector<fastjet::PseudoJet> jets( clusterSequence->inclusive_jets (mJetPtMin) );
  unsigned int nJets( jets.size() );

  if ( nJets == 0 ) 
    {
      delete clusterSequence;
      return kFALSE;
    }
  //Double_t ptByArea[ nJets ];

  //   int columnwidth( 10 );
  //cout << "found " << jets.size() << " jets" << endl;
  //   cout.width( 5 );
  //   cout << "jet";
  //   cout.width( columnwidth );
  //   cout << "eta";
  //   cout.width( columnwidth );
  //   cout << "phi";
  //   cout.width( columnwidth );
  //   cout << "pT";
  //   cout.width( columnwidth );
  //   cout << "jetArea";
  //   cout.width( 15 );
  //   cout << "pT / jetArea";
  //   cout << endl;
  
  _jets.reserve( nJets );

  vector< fastjet::PseudoJet > sorted_jets ( sorted_by_pt( jets ));
  for ( int i(0); i<nJets; ++i )
    {
      //ptByArea[i] = jets[i].perp()/clusterSequence->area(jets[i]);

      //       cout.width( 5 );
      //       cout << i;
      //       cout.width( columnwidth );
      //       cout << jets[i].eta();
      //       cout.width( columnwidth );
      //       cout << jets[i].phi();
      //       cout.width( columnwidth );
      //       cout << jets[i].perp();
      //       cout.width( columnwidth );
      //       cout << clusterSequence->area(jets[i]);
      //       cout.width( 15 );
      //       cout << ptByArea[i];
      //       cout << endl;

      /// save
      ///
      /// TLorentzVector
      /// area
      /// nconstituents
      
      fastjet::PseudoJet jet( sorted_jets[i] );
      vector< fastjet::PseudoJet > constituents( clusterSequence->constituents(jet) );
      
      TLorentzVector* mom    = new TLorentzVector( jet.px(), jet.py(), jet.pz(), jet.e() );
      double          area   = clusterSequence->area(jet);
      //  double          median = TMath::Median( nJets, ptByArea );
      unsigned int    nconst = constituents.size();
      
      UEJetWithArea* theJet = new UEJetWithArea( *mom, area, nconst);
      //_jets[i] = *theJet;
      _jets.push_back( *theJet );

      delete mom;
      delete theJet;
    }
  delete clusterSequence;

  return kTRUE;
}
コード例 #15
0
ファイル: DelphesSaveGenJets.cpp プロジェクト: jlingema/FCCSW
StatusCode DelphesSaveGenJets::saveOutput(Delphes& delphes, const fcc::MCParticleCollection& mcParticles) {
  // Create the collections
  auto colGenJets = m_genJets.createAndPut();
  auto colTaggedJets = m_taggedGenJets.createAndPut();

  const TObjArray* delphesColl = delphes.ImportArray(m_delphesArrayName.c_str());
  if (delphesColl == nullptr) {
    warning() << "Delphes collection " << m_delphesArrayName << " not present. Skipping it." << endmsg;
    return StatusCode::SUCCESS;
  }

  for(int j = 0; j < delphesColl->GetEntries(); ++j) {

    auto cand = static_cast<Candidate *>(delphesColl->At(j));

    // Jet info
    auto jet         = colGenJets->create();
    auto bareJet     = fcc::BareJet();
    bareJet.area     = -1;
    bareJet.p4.px    = cand->Momentum.Px();
    bareJet.p4.py    = cand->Momentum.Py();
    bareJet.p4.pz    = cand->Momentum.Pz();
    bareJet.p4.mass  = cand->Mass;
    jet.core(bareJet);

    // Flavor-tag info
    auto flavorGenJet = colTaggedJets->create();
    flavorGenJet.tag(cand->Flavor);
    flavorGenJet.jet(jet);

    // Debug: print FCC-EDM jets info
    if (msgLevel() <= MSG::DEBUG) {

      double energy = sqrt(jet.p4().px*jet.p4().px +
                           jet.p4().py*jet.p4().py +
                           jet.p4().pz*jet.p4().pz +
                           jet.p4().mass*jet.p4().mass);

      debug() << "Gen Jet: "
              << " Id: "       << std::setw(3)  << j+1
              << " Flavor: "   << std::setw(3)  << flavorGenJet.tag()
              << std::scientific
              << " Px: "       << std::setprecision(2) << std::setw(9) << jet.p4().px
              << " Py: "       << std::setprecision(2) << std::setw(9) << jet.p4().py
              << " Pz: "       << std::setprecision(2) << std::setw(9) << jet.p4().pz
              << " E: "        << std::setprecision(2) << std::setw(9) << energy
              << " M: "        << std::setprecision(2) << std::setw(9) << jet.p4().mass
              << std::fixed
              << std::endl;
    }

    // Reference to MC - Delphes holds references to all objects related to the Jet object,
    // several relations might exist -> find "recursively" in a tree history the MC particle.
    // Add index to the reference index field to avoid double counting
    std::set<int> idRefMCPart; // Avoid double counting when referencingh MC particles

    // Recursive procedure stops after the relation found is the one to MC particle and not to
    // a particle object. If particle not related to MC particle (<0 value)
    findJetPartMC(cand, mcParticles.size(), idRefMCPart);

    // Debug: print variable
    double totSimE = 0;

    for (auto id : idRefMCPart) {
      auto& mcParticle = mcParticles.at(id);
      jet.addparticles(mcParticles.at(id));

      // Debug: print FCC-EDM jet relation info
      if (msgLevel() <= MSG::DEBUG) {
        double recE   = sqrt(jet.p4().px*jet.p4().px +
                             jet.p4().py*jet.p4().py +
                             jet.p4().pz*jet.p4().pz +
                             jet.p4().mass*jet.p4().mass);
        double simE   = sqrt(mcParticle.p4().px*mcParticle.p4().px +
                             mcParticle.p4().py*mcParticle.p4().py +
                             mcParticle.p4().pz*mcParticle.p4().pz +
                             mcParticle.p4().mass*mcParticle.p4().mass);
        totSimE += simE;
        debug() << " RefId: " << std::setw(3)            << id+1
                << " Rel E: " << std::setprecision(2)
                              << std::scientific
                              << std::setw(9) << simE    << " "
                              << std::setw(9) << totSimE << " <-> "
                              << std::setw(9) << recE
                              << std::fixed
                              << std::endl;
      } // Debug
    }

    // Debug: print end-line
    if (msgLevel() <= MSG::DEBUG) debug() << endmsg;
  } // For - jets
  return StatusCode::SUCCESS;
}
コード例 #16
0
IGL_INLINE void igl::jet(const T x, T * rgb)
{
  return jet(x,rgb[0],rgb[1],rgb[2]);
}
コード例 #17
0
ファイル: meoutput.C プロジェクト: rebecacern/UserCode
void meoutput(int nsel = 1, int mode = 0, bool silent = false){
  
   
  
  // samples used
  double x_sec = 0.;
  char plotName[300];
  sprintf(plotName,"test");
  
  if (nsel == 0)                	{sprintf(plotName,"tt");}
  else if (nsel == 1)   		{sprintf(plotName,"tw");}
  
  
  if (mode != 0 &&  mode !=1 && mode !=2) mode = 0;
  if (!silent){
    if      (mode == 0) 	cout << " Electron-Muon Mixed channel " << endl;
    else if (mode == 1) 	cout << " Di-Muon channel " << endl;
    else if (mode == 2) 	cout << " Di-Electron channel " << endl;
  }
  
  char myRootFile[300];
  sprintf(myRootFile,"outputs/out_%d_%s.root", mode, plotName);
  TFile *input = TFile::Open(myRootFile);
  
  
  char myTexFile[300];
  sprintf(myTexFile,"out/%s_%d.lhco", plotName, mode);
  ofstream salida(myTexFile);
  
  // tree variables
  /////
  double xlWeight; 
  
  double metPt;
  double metPx;
  double metPy;
  
  std::vector<double> *ptLepton;
  std::vector<double> *pxLepton;
  std::vector<double> *pyLepton;
  std::vector<double> *pzLepton;
  std::vector<double> *eLepton;
  std::vector<double> *qLepton;
  
  std::vector<double> *ptJet;
  std::vector<double> *pxJet;
  std::vector<double> *pyJet;
  std::vector<double> *pzJet;
  std::vector<double> *eJet;
  std::vector<double> *qJet;
  std::vector<double> *btJet;
  
  TTree*Tree = (TTree*) gROOT->FindObject("myTree");
  
  Tree->SetBranchAddress("xlWeight", &xlWeight);
  
  Tree->SetBranchAddress("metPt", &metPt);
  Tree->SetBranchAddress("metPx", &metPx);
  Tree->SetBranchAddress("metPy", &metPy);
  
  Tree->SetBranchAddress("ptLepton",&ptLepton);
  Tree->SetBranchAddress("pxLepton",&pxLepton);
  Tree->SetBranchAddress("pyLepton",&pyLepton);
  Tree->SetBranchAddress("pzLepton",&pzLepton);
  Tree->SetBranchAddress("eLepton",&eLepton);
  Tree->SetBranchAddress("qLepton",&qLepton);
  
  Tree->SetBranchAddress("ptJet",&ptJet);
  Tree->SetBranchAddress("pxJet",&pxJet);
  Tree->SetBranchAddress("pyJet",&pyJet);
  Tree->SetBranchAddress("pzJet",&pzJet);
  Tree->SetBranchAddress("eJet",&eJet);
  Tree->SetBranchAddress("qJet",&qJet);
  Tree->SetBranchAddress("btJet",&btJet);
  
  int nEvents = Tree->GetEntries();
  if(!silent){
    cout << endl;
    cout << "------------------------------------------" << endl;
    cout << "Sample: " << plotName <<  endl;
    cout << "------------------------------------------" << endl;
    cout << "Number of Total events in the tuple: " <<  nEvents << endl;
    cout << "------------------------------------------" << endl;
  }
  
  
  //////////
  int n1Jet = 0;
  int nTotal = 0;
  int nUsed = 0;
  
  for(int event = 0; event<nEvents; event++){
    
    Tree->GetEntry(event);
    
    if (luminosity != 1000) xlWeight*=(luminosity/1000);
    
    if(ptLepton->size() != 2) cout << "Something is wrong, your Tree is not correctly filled" << endl;
    else {
      
      TLorentzVector lepton0(pxLepton->at(0),pyLepton->at(0), pzLepton->at(0), eLepton->at(0));
      TLorentzVector lepton1(pxLepton->at(1),pyLepton->at(1), pzLepton->at(1), eLepton->at(1)); 
      TLorentzVector pair = lepton0+lepton1;
      
      bool invMass = false;
      if      (mode == 0) invMass = true;
      else if (mode == 1 && (pair.M() > invMax || pair.M() < invMin)) invMass = true;
      else if (mode == 2 && (pair.M() > invMax || pair.M() < invMin)) invMass = true;
      
      if (invMass){
	if (metPt >= metCut || mode ==0){
	  
	  int nJets = 0;
	  int nSecondJets = 0;
	  int nJetsBt = 0;
	  bool bTagged = false;
	  int indexJet = -5;
	  for (int i=0; i < ptJet->size(); i++){
	    TLorentzVector tempJet(pxJet->at(i),pyJet->at(i), pzJet->at(i), eJet->at(i));
	    if (tempJet.Pt()  >= jetCut && TMath::Min(fabs(lepton0.DeltaR(tempJet)), fabs(lepton1.DeltaR(tempJet))) > 0.3){
	      nJets++;
	      indexJet = i;
	      if(btJet->at(i) > 1.74) bTagged = true;
	    } else if (tempJet.Pt()  >= secondJetCut && TMath::Min(fabs(lepton0.DeltaR(tempJet)), fabs(lepton1.DeltaR(tempJet))) > 0.3) nSecondJets++;
	    if (btJet->at(i) > 1.74) nJetsBt++;
	    
	  }
	  
	  if (nJets == 1){
	    if (nJetsBt == 1 && bTagged){
	      // if (bTagged && nSecondJets == 0){
	      TLorentzVector jet(pxJet->at(indexJet),pyJet->at(indexJet), pzJet->at(indexJet), eJet->at(indexJet));
	      
	      double ptSysPx = lepton0.Px() + lepton1.Px() + jet.Px() + metPx;
	      double ptSysPy = lepton0.Py() + lepton1.Py() + jet.Py() + metPy;
	      double ptSystem = sqrt(ptSysPx*ptSysPx + ptSysPy*ptSysPy);
	      double ht = lepton0.Pt() + lepton1.Pt() + jet.Pt() + metPt; 
	      
	      if (ptSystem <= ptsysCut){
		if (ht > htMin || mode !=0){
		  nTotal++;
		  if (nSecondJets != 0){
		    nUsed++;
		    int indexSecondJet = -5;
		    for (int i=0; i < ptJet->size(); i++){
		      TLorentzVector tempJet(pxJet->at(i),pyJet->at(i), pzJet->at(i), eJet->at(i));
		      if (i != indexJet && TMath::Min(fabs(lepton0.DeltaR(tempJet)), fabs(lepton1.DeltaR(tempJet))) > 0.3){
			indexSecondJet = i;
			break;
		      } 
		    }
		    
		    TLorentzVector jet2(pxJet->at(indexSecondJet),pyJet->at(indexSecondJet), pzJet->at(indexSecondJet), eJet->at(indexSecondJet));
		    TVector3 missingEt(metPx, metPy, 0);
		    
		    salida << "0 1 1 " << endl;
		    salida << "1 2 " << lepton0.Eta() << " " << lepton0.Phi() << " " << lepton0.Pt() <<" " << lepton0.M() << " " << qLepton->at(0) << " 0 0 0 0 " <<  endl;
		    salida << "2 2 " << lepton1.Eta() << " " << lepton1.Phi() << " " << lepton1.Pt() <<" " << lepton1.M() << " " << qLepton->at(1) << " 0 0 0 0 " <<  endl;
		    salida << "3 4 " << jet.Eta() << " " << jet.Phi() << " " << jet.Pt() <<" " << jet.M() << " " << qJet->at(indexJet) << " 2 0 0 0 " <<  endl;
		    salida << "4 4 " << jet2.Eta() << " " << jet2.Phi() << " " << jet2.Pt() <<" " << jet2.M() << " " << qJet->at(indexSecondJet) << " 2 0 0 0 " <<  endl;
		    salida << "5 6 " << missingEt.Eta() << " " << missingEt.Phi() << " " << metPt <<" " << " 0 0 0 0 0 0 " <<  endl;
		    
		  } else n1Jet++;
		  
		  
		  
	       	}
	      }
	    }
	  }
	}
      }
      
    } // 2 leptons
  } // events
  
  
  if (!silent){ 
    cout << "Results: "  <<  endl;
    cout << nTotal << " events passed the selection" << endl;
    cout << nUsed << " events were used in the lhco file " << endl;
    cout << n1Jet << " events were not used (only 1 jet exactly) " << endl;
    cout << "------------------------------------------" << endl; 
  }

  
  
}
コード例 #18
0
ファイル: looper.C プロジェクト: rebecacern/OldVUB
void looper::myLoop(int nsel, int mode, bool silent)
{

  char plotName[300];
  sprintf(plotName,"test");
  
  if (nsel == 0)                	{sprintf(plotName,"tt");}
  else if (nsel == 1)   		{sprintf(plotName,"twdr");}
  else if (nsel == -1)   		{sprintf(plotName,"twds");}
  else if (nsel == 2)   		{sprintf(plotName,"zjets");}
  else if (nsel == 3)   		{sprintf(plotName,"di");}
  else if (nsel == 4)			{sprintf(plotName, "st");}
  else if (nsel == 5)   		{sprintf(plotName,"wjets");}
  else if (nsel == 6)   		{sprintf(plotName,"qcd_mu");}
  else if (nsel == 7)                	{sprintf(plotName,"others");}
  
  else if (nsel == 555)                	{sprintf(plotName,"mc");}
  
  else if (nsel == 666)                	{sprintf(plotName,"data");}
  
  bool nosf = false;
  
  char newRootFile[300];
  double lumi = luminosity; 
  if (mode == 0 )        lumi = 11966.617; 
  else if ( mode == 1)   lumi = 12067.294;
  else if ( mode == 2)   lumi = 12093.792;
  sprintf(newRootFile,"results/an_%dpb_%d.root", (int)lumi, mode);
 
  TFile f_var(newRootFile, "UPDATE");
  
  if(!silent){
    std::cout << "[Info:] results root file " << newRootFile << std::endl;
  }
  
  
  //////////
  char title[300];
  sprintf(title,"cuts_%s",plotName);
  TH1F* histo = new TH1F( title, " ", 10,  0, 10 );
  histo->Sumw2();
  
  sprintf(title,"met_high_%s",plotName);
  TH1F* histo_met_high = new TH1F( title, " ", 100,  0, 200 );
  histo_met_high->Sumw2();
  
  sprintf(title,"met_low_%s",plotName);
  TH1F* histo_met_low = new TH1F( title, " ", 100,  0, 200 );
  histo_met_low->Sumw2();
  
  sprintf(title,"promet_%s",plotName);
  TH1F* histo_promet = new TH1F( title, " ", 100,  0, 200 );
  histo_promet->Sumw2();
  
  sprintf(title,"met_cut_%s",plotName);
  TH1F* histo_met_cut = new TH1F( title, " ", 100,  0, 200 );
  histo_met_cut->Sumw2();
  
  sprintf(title,"met_bt_%s",plotName);
  TH1F* histo_met_bt = new TH1F( title, " ", 100,  0, 200 );
  histo_met_bt->Sumw2();
  
  sprintf(title,"mll_after_%s",plotName);
  TH1F* histo_mll_after = new TH1F( title, " ", 100,  0, 200 );
  histo_mll_after->Sumw2();
  
  sprintf(title,"njets_cut_%s",plotName);
  TH1F* histo_njets_cut = new TH1F( title, " ", 10,  -0.5, 9.5 );
  histo_njets_cut->Sumw2();
  
  sprintf(title,"njetsbt_cut_%s",plotName);
  TH1F* histo_njetsbt_cut = new TH1F( title, " ", 10,   -0.5, 9.5 );
  histo_njetsbt_cut->Sumw2();
  
  sprintf(title,"njetsbt_high_%s",plotName);
  TH1F* histo_njetsbt_high = new TH1F( title, " ", 10,   -0.5, 9.5 );
  histo_njetsbt_high->Sumw2();
  
  sprintf(title,"njetsbt_low_%s",plotName);
  TH1F* histo_njetsbt_low = new TH1F( title, " ", 10,   -0.5, 9.5 );
  histo_njetsbt_low->Sumw2();
  
  sprintf(title,"njets_high_%s",plotName);
  TH1F* histo_njets_high = new TH1F( title, " ", 10,   -0.5, 9.5 );
  histo_njets_high->Sumw2();
  
  sprintf(title,"njets_low_%s",plotName);
  TH1F* histo_njets_low = new TH1F( title, " ", 10,   -0.5, 9.5 );
  histo_njets_low->Sumw2();
  
  sprintf(title,"ptsys_high_%s",plotName);
  TH1F* histo_ptsys_high = new TH1F( title, " ", 100,  0, 200 );
  histo_ptsys_high->Sumw2();
  
  sprintf(title,"ptsys_low_%s",plotName);
  TH1F* histo_ptsys_low = new TH1F( title, " ", 100,  0, 200 );
  histo_ptsys_low->Sumw2();
  
  sprintf(title,"ht_high_%s",plotName);
  TH1F* histo_ht_high = new TH1F( title, " ", 300,  0, 600 );
  histo_ht_high->Sumw2();
  
  sprintf(title,"ht_low_%s",plotName);
  TH1F* histo_ht_low = new TH1F( title, " ", 300,  0, 600 );
  histo_ht_low->Sumw2();
  
  sprintf(title,"ht_cut_%s",plotName);
  TH1F* histo_ht_cut = new TH1F( title, " ", 300,  0, 600 );
  histo_ht_cut->Sumw2();
  
  sprintf(title,"pt_max_%s",plotName);
  TH1F* histo_pt_max = new TH1F( title, " ", 100,  0, 200 );
  histo_pt_max->Sumw2();
  
  sprintf(title,"pt_min_%s",plotName);
  TH1F* histo_pt_min = new TH1F( title, " ", 100,  0, 200 );
  histo_pt_min->Sumw2();
  
  sprintf(title,"btagHE_%s",plotName);
  TH2F* histo_btagHE = new TH2F( title, " ", 300,  -200, 100, 100, -2, 7);
  histo_btagHE->Sumw2();
  
  sprintf(title,"btagHP_%s",plotName);
  TH2F* histo_btagHP = new TH2F( title, " ", 300,  -200, 100, 100, -2, 7);
  histo_btagHP->Sumw2();
  
  sprintf(title,"etalepton_%s",plotName);
  TH1F* histo_etalepton = new TH1F( title, " ", 101,  -3, 3);
  histo_etalepton->Sumw2();
  
  sprintf(title,"ht_bf_%s",plotName);
  TH1F* histo_ht_bf = new TH1F( title, " ", 300,  0, 600 );
  histo_ht_bf->Sumw2();
  
  sprintf(title,"ptsys_bf_%s",plotName);
  TH1F* histo_ptsys_bf = new TH1F( title, " ", 100,  0, 200 );
  histo_ptsys_bf->Sumw2();
  
  sprintf(title,"npu_%s",plotName);
  TH1F* histo_npu = new TH1F( title, " ", 30,   -0.5, 29.5 );
  histo_npu->Sumw2();
  
  
  /// Classic plotmaker plots
  sprintf(title,"met_%s",plotName);
  TH1F* histo_met = new TH1F( title, " ", 100,  0, 200 );
  histo_met->Sumw2();
  
  sprintf(title,"mll_%s",plotName);
  TH1F* histo_mll = new TH1F( title, " ", 100,  0, 200 );
  histo_mll->Sumw2();
  
  sprintf(title,"njets_%s",plotName);
  TH1F* histo_njets = new TH1F( title, " ", 10,  0, 10 );
  histo_njets->Sumw2();
  
  sprintf(title,"njetsbt_%s",plotName);
  TH1F* histo_njetsbt = new TH1F( title, " ", 10,  -0.5, 9.5 );
  histo_njetsbt->Sumw2();
  
  sprintf(title,"ptsys_%s",plotName);
  TH1F* histo_ptsys = new TH1F( title, " ", 200,  0, 200 );
  histo_ptsys->Sumw2();
  
  sprintf(title,"ht_%s",plotName);
  TH1F* histo_ht = new TH1F( title, " ", 300,  0, 600 );
  histo_ht->Sumw2();
  
  sprintf(title,"pt_leading_%s",plotName);
  TH1F* histo_pt_leading = new TH1F( title, " ", 100,  0, 200 );
  histo_pt_leading->Sumw2();
  
  sprintf(title,"nvertex_%s",plotName);
  TH1F* histo_nvertex = new TH1F( title, " ", 70,   -0.5, 69.5 );
  histo_nvertex->Sumw2();
  
  sprintf(title,"nloosejets_%s",plotName);
  TH1F* histo_nloosejets = new TH1F( title, " ", 10,  -0.5, 9.5 );
  histo_nloosejets->Sumw2();
  
  sprintf(title,"nloosejets_bt_%s",plotName);
  TH1F* histo_nloosejets_bt = new TH1F( title, " ", 10,  -0.5, 9.5 );
  histo_nloosejets_bt->Sumw2();
 
  
  // 1 jet level
  /// Classic plotmaker plots
  sprintf(title,"met_1j_%s",plotName);
  TH1F* histo_met_1j = new TH1F( title, " ", 100,  0, 200 );
  histo_met_1j->Sumw2();
  
  sprintf(title,"mll_1j_%s",plotName);
  TH1F* histo_mll_1j = new TH1F( title, " ", 100,  0, 200 );
  histo_mll_1j->Sumw2();
  
  sprintf(title,"ptsys_1j_%s",plotName);
  TH1F* histo_ptsys_1j = new TH1F( title, " ", 100,  0, 200 );
  histo_ptsys_1j->Sumw2();
  
  sprintf(title,"ht_1j_%s",plotName);
  TH1F* histo_ht_1j = new TH1F( title, " ", 300,  0, 600 );
  histo_ht_1j->Sumw2();
  
  sprintf(title,"pt_leading_1j_%s",plotName);
  TH1F* histo_pt_leading_1j = new TH1F( title, " ", 100,  0, 200 );
  histo_pt_leading_1j->Sumw2();
  
  sprintf(title,"nvertex_1j_%s",plotName);
  TH1F* histo_nvertex_1j = new TH1F( title, " ", 30,   -0.5, 29.5 );
  histo_nvertex_1j->Sumw2();
  
  // 1 jet level
  /// Classic plotmaker plots
  sprintf(title,"met_1j1t_%s",plotName);
  TH1F* histo_met_1j1t = new TH1F( title, " ", 100,  0, 200 );
  histo_met_1j1t->Sumw2();
  
  sprintf(title,"mll_1j1t_%s",plotName);
  TH1F* histo_mll_1j1t = new TH1F( title, " ", 100,  0, 200 );
  histo_mll_1j1t->Sumw2();
  
  sprintf(title,"ptsys_1j1t_%s",plotName);
  TH1F* histo_ptsys_1j1t = new TH1F( title, " ", 100,  0, 200 );
  histo_ptsys_1j1t->Sumw2();
  
  sprintf(title,"ht_1j1t_%s",plotName);
  TH1F* histo_ht_1j1t = new TH1F( title, " ", 200,  0, 200 );
  histo_ht_1j1t->Sumw2();
  
  sprintf(title,"pt_leading_1j1t_%s",plotName);
  TH1F* histo_pt_leading_1j1t = new TH1F( title, " ", 100,  0, 200 );
  histo_pt_leading_1j1t->Sumw2();
  
  sprintf(title,"nvertex_1j1t_%s",plotName);
  TH1F* histo_nvertex_1j1t = new TH1F( title, " ", 30,   -0.5, 29.5 );
  histo_nvertex_1j1t->Sumw2();
  
  
  // 2j1t
  /// Classic plotmaker plots
  sprintf(title,"met_2j1t_%s",plotName);
  TH1F* histo_met_2j1t = new TH1F( title, " ", 100,  0, 200 );
  histo_met_2j1t->Sumw2();
  
  sprintf(title,"mll_2j1t_%s",plotName);
  TH1F* histo_mll_2j1t = new TH1F( title, " ", 100,  0, 200 );
  histo_mll_2j1t->Sumw2();
  
  sprintf(title,"ptsys_2j1t_%s",plotName);
  TH1F* histo_ptsys_2j1t = new TH1F( title, " ", 200,  0, 200 );
  histo_ptsys_2j1t->Sumw2();
  
  sprintf(title,"ht_2j1t_%s",plotName);
  TH1F* histo_ht_2j1t = new TH1F( title, " ", 300,  0, 600 );
  histo_ht_2j1t->Sumw2();
  
  sprintf(title,"pt_leading_2j1t_%s",plotName);
  TH1F* histo_pt_leading_2j1t = new TH1F( title, " ", 100,  0, 200 );
  histo_pt_leading_2j1t->Sumw2();
  
  sprintf(title,"nvertex_2j1t_%s",plotName);
  TH1F* histo_nvertex_2j1t = new TH1F( title, " ", 30,   -0.5, 29.5 );
  histo_nvertex_2j1t->Sumw2();
  
  
  // 2j2t
  /// Classic plotmaker plots
  sprintf(title,"met_2j2t_%s",plotName);
  TH1F* histo_met_2j2t = new TH1F( title, " ", 100,  0, 200 );
  histo_met_2j2t->Sumw2();
  
  sprintf(title,"mll_2j2t_%s",plotName);
  TH1F* histo_mll_2j2t = new TH1F( title, " ", 100,  0, 200 );
  histo_mll_2j2t->Sumw2();
  
  sprintf(title,"ptsys_2j2t_%s",plotName);
  TH1F* histo_ptsys_2j2t = new TH1F( title, " ", 300,  0, 600 );
  histo_ptsys_2j2t->Sumw2();
  
  sprintf(title,"ht_2j2t_%s",plotName);
  TH1F* histo_ht_2j2t = new TH1F( title, " ", 300,  0, 600 );
  histo_ht_2j2t->Sumw2();
  
  sprintf(title,"pt_leading_2j2t_%s",plotName);
  TH1F* histo_pt_leading_2j2t = new TH1F( title, " ", 100,  0, 200 );
  histo_pt_leading_2j2t->Sumw2();
  
  sprintf(title,"nvertex_2j2t_%s",plotName);
  TH1F* histo_nvertex_2j2t = new TH1F( title, " ", 30,   -0.5, 29.5 );
  histo_nvertex_2j2t->Sumw2();

  
  // all regions
  sprintf(title,"R_%s",plotName);
  TH1F* histo_R = new TH1F( title, " ", 40,  0, 40 );
  histo_R->Sumw2();
  
  
  sprintf(title,"nvertex_2lep_%s",plotName);
  TH1F* histo_nvertex_2lep = new TH1F( title, " ", 70,   -0.5, 69.5 );
  histo_nvertex_2lep->Sumw2();


  // Test jets
  sprintf(title,"ht_2j1t_leading_%s",plotName);
  TH1F* histo_ht_2j1t_leading = new TH1F( title, " ", 300,  0, 600 );
  histo_ht_2j1t_leading->Sumw2();
  
  sprintf(title,"ht_2j1t_all_%s",plotName);
  TH1F* histo_ht_2j1t_all = new TH1F( title, " ", 300,  0, 600 );
  histo_ht_2j1t_all->Sumw2();
  
  sprintf(title,"ht_2j2t_leading_%s",plotName);
  TH1F* histo_ht_2j2t_leading = new TH1F( title, " ", 300,  0, 600 );
  histo_ht_2j1t_leading->Sumw2();
  
  sprintf(title,"ht_2j2t_all_%s",plotName);
  TH1F* histo_ht_2j2t_all = new TH1F( title, " ", 300,  0, 600 );
  histo_ht_2j2t_all->Sumw2();
  
  sprintf(title,"ptsys_2j1t_leading_%s",plotName);
  TH1F* histo_ptsys_2j1t_leading = new TH1F( title, " ", 200,  0, 200 );
  histo_ptsys_2j1t_leading->Sumw2();
  
  sprintf(title,"ptsys_2j1t_all_%s",plotName);
  TH1F* histo_ptsys_2j1t_all = new TH1F( title, " ", 200,  0, 200 );
  histo_ptsys_2j1t_all->Sumw2();
  
  sprintf(title,"ptsys_2j2t_leading_%s",plotName);
  TH1F* histo_ptsys_2j2t_leading = new TH1F( title, " ", 200,  0, 200 );
  histo_ptsys_2j1t_leading->Sumw2();
  
  sprintf(title,"ptsys_2j2t_all_%s",plotName);
  TH1F* histo_ptsys_2j2t_all = new TH1F( title, " ", 200,  0, 200 );
  histo_ptsys_2j2t_all->Sumw2();



  if (fChain == 0) return;
  
  Long64_t nentries = fChain->GetEntriesFast();
  
  Long64_t nbytes = 0, nb = 0;
  for (Long64_t jentry=0; jentry<nentries;jentry++) {
    
    
    Long64_t ientry = LoadTree(jentry);
    if (ientry < 0) break;
    nb = fChain->GetEntry(jentry);   nbytes += nb;
    
    
    if (lumi != lum && nsel != 666 && mode !=3){
      if (jentry == 0)std::cout << "[Warning:] This tree was made with a different luminosity (" << lum << ") than " << lumi << std::endl;
      //xlWeight*=(lumi/lum);
    }
    
    if(ptLepton->size() != 2){
      std::cout << "[Warning:] Something is wrong, your Tree is not correctly filled" << std::endl;
      break;
    } else {
      histo->Fill(0.,xlWeight);
      histo_nvertex_2lep->Fill(nvertex,xlWeight);
      TLorentzVector lepton0(pxLepton->at(0),pyLepton->at(0), pzLepton->at(0), eLepton->at(0));
      TLorentzVector lepton1(pxLepton->at(1),pyLepton->at(1), pzLepton->at(1), eLepton->at(1)); 
      TLorentzVector pair = lepton0+lepton1;
      
      //if (ptLepton->at(0) < 40 && ptLepton->at(1) < 40) continue;
       if(ptLepton->at(0) < 30 || ptLepton->at(1) < 30)continue;
      
      double phipairmet_t = 0;
      double pi_m = 3.1416/2;
      phipairmet_t = pi_m;
      
      TVector3 vmet(metPx, metPy, 0);
      
      double promet = metPt*sin(phipairmet_t);
      TVector3 m0(pxLepton->at(0),pyLepton->at(0), pzLepton->at(0));
      TVector3 m1(pxLepton->at(1),pyLepton->at(1), pzLepton->at(1)); 
      if (fabs(m0.DeltaPhi(vmet)) < phipairmet_t) phipairmet_t = fabs(m0.DeltaPhi(vmet));
      if (fabs(m1.DeltaPhi(vmet)) < phipairmet_t) phipairmet_t = fabs(m1.DeltaPhi(vmet));
      
      if (phipairmet_t == pi_m) promet = metPt;
      
      if (pair.M() > 20){
	histo->Fill(1, xlWeight);

	double SFval, SFerror;
	if ( nsel == 666 || nosf){
	  SFval = 1;
	  SFerror = 0;
	} else if (nsel == 0){
	  SFval = 0.95;
	  SFerror = 0.03;
	} else {
	  SFval = 0.97;
	  SFerror = 0.03;
	}
	
	
	int nJetsBT = 0;
	int nTightJetsBT = 0;
	int nJets = 0;
	bool bTagged = false;
	int iJet = -5;
	int iSF;
	double tempSF = SFval;
	int iLead = -5;
	
	int SFvalue = int(tempSF*100);
	int nloose = 0;
	int nloosebt = 0;
	
	for (unsigned int i =0; i < ptJet->size(); i ++){ 
	  TLorentzVector tempJet(pxJet->at(i),pyJet->at(i), pzJet->at(i), eJet->at(i));
	  if (ptJet->at(i) > 30 && fabs(tempJet.Eta()) < 2.5 && TMath::Min(fabs(lepton0.DeltaR(tempJet)), fabs(lepton1.DeltaR(tempJet))) > 0.3) {
	    nJets++;
	    iJet = i;
	    if (iLead == -5) iLead = iJet;
	    if (btCSVBJet->at(i) > 0.679){
	      iSF = rand() % 100;
	      if (iSF < SFvalue ){
		bTagged = true;
		nJetsBT++;
		nTightJetsBT++;
	      } 
	    } 
	  } else if (btCSVBJet->at(i) > 0.679 && fabs(tempJet.Eta()) < 2.5){
	    iSF = rand() % 100;
	    if (iSF < SFvalue ){ nJetsBT++; nloosebt++;}
	  }
	  
	  if (ptJet->at(i) <= 30 || fabs(tempJet.Eta()) >= 2.5) nloose++;
	}
	
	histo_nloosejets->Fill(nloose, xlWeight);
	histo_nloosejets_bt->Fill(nloosebt, xlWeight);

	histo_pt_max->Fill(TMath::Max(lepton0.Pt(), lepton1.Pt()), xlWeight);
	histo_pt_min->Fill(TMath::Min(lepton0.Pt(), lepton1.Pt()), xlWeight);
	histo_njets->Fill(nJets,  xlWeight);
	histo_njetsbt->Fill(nJetsBT,  xlWeight);
	histo_mll->Fill(pair.M(),  xlWeight);
	histo_met->Fill(metPt,  xlWeight);
	histo_promet->Fill(promet, xlWeight);
	
	if (nvertex > 5){
	  histo_met_high->Fill(metPt,  xlWeight);
	  histo_njets_high->Fill(nJets,  xlWeight);
	  histo_njetsbt_high->Fill(nJetsBT,  xlWeight);
	} else {
	  histo_met_low->Fill(metPt,  xlWeight);
	  histo_njets_low->Fill(nJets,  xlWeight);
	  histo_njetsbt_low->Fill(nJetsBT,  xlWeight);  
	}
	
	if (nJets) histo_pt_leading->Fill(ptJet->at(0), xlWeight);
	if (nJets == 1){
	  histo_etalepton->Fill(lepton0.Eta(), xlWeight);
	  TLorentzVector jet(pxJet->at(iJet),pyJet->at(iJet), pzJet->at(iJet), eJet->at(iJet));
	   
	  double ptSysPx1 = lepton0.Px() + lepton1.Px() + jet.Px() + metPx;
	  double ptSysPy1 = lepton0.Py() + lepton1.Py() + jet.Py() + metPy;
	  double ptSystem1 = sqrt(ptSysPx1*ptSysPx1 + ptSysPy1*ptSysPy1);
	  double ht1 = lepton0.Pt() + lepton1.Pt() + jet.Pt() + metPt; 
	  histo_ptsys_bf->Fill(ptSystem1, xlWeight);
	  histo_ht_bf->Fill(ht1, xlWeight);
	}
	bool invMass = false;
	if      (mode == 0) invMass = true;
	else if (mode == 1  && (pair.M() > invMax || pair.M() < invMin)) invMass = true;
	else if (mode == 2 && (pair.M() > invMax || pair.M() < invMin)) invMass = true;
	

	if (invMass){
	  histo->Fill(2, xlWeight);
	  histo_mll_after->Fill(pair.M(),  xlWeight);
	  histo_met_cut->Fill(metPt,  xlWeight);
	  if (metPt >= metCut || mode ==0){
	   
	    histo->Fill(3, xlWeight);
	    histo_njets_cut->Fill(nJets, xlWeight);
	    if (nJets == 1){
	      histo->Fill(4, xlWeight);
	      histo_njetsbt_cut->Fill(nJetsBT, xlWeight);
	      TLorentzVector jet(pxJet->at(iJet),pyJet->at(iJet), pzJet->at(iJet), eJet->at(iJet));
		
	      double ptSysPx = lepton0.Px() + lepton1.Px() + jet.Px() + metPx;
	      double ptSysPy = lepton0.Py() + lepton1.Py() + jet.Py() + metPy;
	      double ptSystem = sqrt(ptSysPx*ptSysPx + ptSysPy*ptSysPy);
	      double ht = lepton0.Pt() + lepton1.Pt() + jet.Pt() + metPt; 
	      
	      histo_mll_1j->Fill(pair.M(),  xlWeight);
	      histo_met_1j->Fill(metPt,  xlWeight);
	      histo_ptsys_1j->Fill(ptSystem, xlWeight);
	      histo_ht_1j->Fill(ht, xlWeight);
	      histo_pt_leading_1j->Fill(jet.Pt(), xlWeight);
	      
	      
	      if (nJets == 1 && nTightJetsBT == 1 && bTagged && nJetsBT == 1){
		histo->Fill(5, xlWeight);
		
	      
	        histo_mll_1j1t->Fill(pair.M(),  xlWeight);
	        histo_met_1j1t->Fill(metPt,  xlWeight);
	        histo_ptsys_1j1t->Fill(ptSystem, xlWeight);
	        histo_ht_1j1t->Fill(ht, xlWeight);
	        histo_pt_leading_1j1t->Fill(jet.Pt(), xlWeight);
	      
		histo_ptsys->Fill(ptSystem, xlWeight);
		histo_ht->Fill(ht, xlWeight);
		
		histo_met_bt->Fill(metPt, xlWeight);
		
		histo_nvertex->Fill(nvertex, xlWeight);
		histo_npu->Fill(npu, xlWeight);
		
		if (nvertex > 5) {
		  histo_ptsys_high->Fill(ptSystem, xlWeight);
		  histo_ht_high->Fill(ht, xlWeight);
		} else {
		  histo_ptsys_low->Fill(ptSystem, xlWeight);
		  histo_ht_low->Fill(ht, xlWeight);
		  
		}
		
		if (ht > htMin || mode !=0){
		  histo->Fill(6, xlWeight);
		  histo_ht_cut->Fill(ht, xlWeight);
		 
		  
		}
	      }
	    }
	  }
	  
	  
	  //Filling of all region from here
	  if (metPt >= metCut || mode ==0){
	
	    if (nJets != 0){
	      
	      TLorentzVector jet(pxJet->at(iJet),pyJet->at(iJet), pzJet->at(iJet), eJet->at(iJet));
	      
	      double ptSysPx = lepton0.Px() + lepton1.Px() + jet.Px() + metPx;
	      double ptSysPy = lepton0.Py() + lepton1.Py() + jet.Py() + metPy;
	      double ptSystem = sqrt(ptSysPx*ptSysPx + ptSysPy*ptSysPy);
	      double ht = lepton0.Pt() + lepton1.Pt() + jet.Pt() + metPt; 
	      
	      if (nJets == 2 && nTightJetsBT == 1 && nJetsBT == 1) {
	        histo_mll_2j1t->Fill(pair.M(),  xlWeight);
	        histo_met_2j1t->Fill(metPt,  xlWeight);
	        histo_ptsys_2j1t->Fill(ptSystem, xlWeight);
	        histo_ht_2j1t->Fill(ht, xlWeight);
	        histo_pt_leading_2j1t->Fill(jet.Pt(), xlWeight);
		TLorentzVector jet2(pxJet->at(iLead),pyJet->at(iLead), pzJet->at(iLead), eJet->at(iLead));
		double htled = lepton0.Pt() + lepton1.Pt() + jet2.Pt() + metPt; 
		histo_ht_2j1t_leading->Fill(htled, xlWeight);
		double htall = lepton0.Pt() + lepton1.Pt() + jet.Pt() + jet2.Pt() + metPt; 
		histo_ht_2j1t_all->Fill(htall, xlWeight);
		
		 
		double ptSysPxled = lepton0.Px() + lepton1.Px() + jet2.Px() + metPx;
		double ptSysPyled = lepton0.Py() + lepton1.Py() + jet2.Py() + metPy;
		double ptSystemled = sqrt(ptSysPxled*ptSysPxled + ptSysPyled*ptSysPyled);
	      	histo_ptsys_2j1t_leading->Fill(ptSystemled, xlWeight);
		
		double ptSysPxall = lepton0.Px() + lepton1.Px() + jet.Px() + jet2.Px() + metPx;
		double ptSysPyall = lepton0.Py() + lepton1.Py() + jet.Py() + jet2.Py() + metPy;
		double ptSystemall = sqrt(ptSysPxall*ptSysPxall + ptSysPyall*ptSysPyall);
	      	histo_ptsys_2j1t_all->Fill(ptSystemall, xlWeight);
		
		
		
		
		
		
	      } else if (nJets == 2 && nTightJetsBT == 2 && nJetsBT == 2)  {
	        histo_mll_2j2t->Fill(pair.M(),  xlWeight);
	        histo_met_2j2t->Fill(metPt,  xlWeight);
	        histo_ptsys_2j2t->Fill(ptSystem, xlWeight);
	        histo_ht_2j2t->Fill(ht, xlWeight);
	        histo_pt_leading_2j2t->Fill(jet.Pt(), xlWeight);
		TLorentzVector jet2(pxJet->at(iLead),pyJet->at(iLead), pzJet->at(iLead), eJet->at(iLead));
		double htled = lepton0.Pt() + lepton1.Pt() + jet2.Pt() + metPt; 
		histo_ht_2j2t_leading->Fill(htled, xlWeight);
		double htall = lepton0.Pt() + lepton1.Pt() + jet.Pt() + jet2.Pt() + metPt; 
		histo_ht_2j2t_all->Fill(htall, xlWeight);    
	
	
	
		double ptSysPxled = lepton0.Px() + lepton1.Px() + jet2.Px() + metPx;
		double ptSysPyled = lepton0.Py() + lepton1.Py() + jet2.Py() + metPy;
		double ptSystemled = sqrt(ptSysPxled*ptSysPxled + ptSysPyled*ptSysPyled);
	      	histo_ptsys_2j2t_leading->Fill(ptSystemled, xlWeight);
		
		double ptSysPxall = lepton0.Px() + lepton1.Px() + jet.Px() + jet2.Px() + metPx;
		double ptSysPyall = lepton0.Py() + lepton1.Py() + jet.Py() + jet2.Py() + metPy;
		double ptSystemall = sqrt(ptSysPxall*ptSysPxall + ptSysPyall*ptSysPyall);
	      	histo_ptsys_2j2t_all->Fill(ptSystemall, xlWeight);
		
		
		
		
		
		
	      }
	      
	      
	   
		  
	      //All possible regions
	      if (nJets == 1 && nTightJetsBT == 1 && bTagged && nJetsBT == 1 && ptSystem <= ptsysCut && (ht > htMin || mode !=0))histo_R->Fill(1, xlWeight); //signal
	      if (nJets == 1 && nTightJetsBT == 2)  histo_R->Fill(2, xlWeight);
	      if (nJets == 1 && nTightJetsBT > 0)  histo_R->Fill(3, xlWeight);
	      if (nJets == 1 && nTightJetsBT > 1)  histo_R->Fill(4, xlWeight);
	      if (nJets == 2 && nTightJetsBT == 0)  histo_R->Fill(5, xlWeight);
	      if (nJets == 2 && nTightJetsBT == 1)  histo_R->Fill(6, xlWeight); //CR1 no ht no ptsys
	      if (nJets == 2 && nTightJetsBT == 2)  histo_R->Fill(7, xlWeight); //CR2 no ht no ptsys
	      if (nJets == 2 && nTightJetsBT > 0)  histo_R->Fill(8, xlWeight);
	      if (nJets == 2 && nTightJetsBT > 1)  histo_R->Fill(9, xlWeight);
	      if (nJets > 1 && nTightJetsBT == 0)  histo_R->Fill(10, xlWeight);
	      if (nJets > 1 && nTightJetsBT == 1)  histo_R->Fill(11, xlWeight);
	      if (nJets > 1 && nTightJetsBT == 2)  histo_R->Fill(12, xlWeight);
	      if (nJets > 1 && nTightJetsBT !=0 )  histo_R->Fill(13, xlWeight);
	      if (nJets > 1 && nTightJetsBT > 1 )  histo_R->Fill(14, xlWeight);
	      if (nJets == 3 && nTightJetsBT ==3 )  histo_R->Fill(15, xlWeight);
	      if (nJets == 1 && nTightJetsBT ==1 && bTagged && nJetsBT == 1)  histo_R->Fill(16, xlWeight);
	      if (nJets == 2 && nTightJetsBT == 1 && ptSystem <= ptsysCut && (ht > htMin || mode !=0))  histo_R->Fill(17, xlWeight); //CR 1 regular
	      if (nJets == 2 && nTightJetsBT == 2 && ptSystem <= ptsysCut && (ht > htMin || mode !=0))  histo_R->Fill(18, xlWeight); //CR 2 regular
	      if (nJets == 2 && nTightJetsBT == 1 && nJetsBT == 1 && ptSystem <= ptsysCut && (ht > htMin || mode !=0))  histo_R->Fill(19, xlWeight);
	      if (nJets == 2 && nTightJetsBT == 2 && nJetsBT == 2 && ptSystem <= ptsysCut && (ht > htMin || mode !=0))  histo_R->Fill(20, xlWeight);
	      if (nJets == 2 && nJetsBT == 1 && ptSystem <= ptsysCut && (ht > htMin || mode !=0))  histo_R->Fill(21, xlWeight); //CR 1 another way
	      if (nJets == 2 && nJetsBT == 2 && ptSystem <= ptsysCut && (ht > htMin || mode !=0))  histo_R->Fill(22, xlWeight); //CR 2 another way
	      if (nJets == 2 && nTightJetsBT == 1 && nJetsBT == 1)  histo_R->Fill(23, xlWeight); //CR1 no ht no ptsys tighter
	      if (nJets == 2 && nTightJetsBT == 2 && nJetsBT == 2)  histo_R->Fill(24, xlWeight); //CR2 no ht no ptsys tighter
	      if (nJets == 2 && nJetsBT == 1)  histo_R->Fill(25, xlWeight); //CR1 no ht no ptsys another flavor
	      if (nJets == 2 && nJetsBT == 2)  histo_R->Fill(26, xlWeight); //CR2 no ht no ptsys another flavor
	      if (nJets == 1 && nTightJetsBT == 1 && bTagged && nJetsBT == 1 && (ht > htMin || mode !=0))histo_R->Fill(27, xlWeight); //signal no ptsys
	      if (nJets == 1 && nTightJetsBT == 1 && bTagged && nJetsBT == 1 && ptSystem <= ptsysCut)histo_R->Fill(28, xlWeight); //signal no ht
	      if (nJets == 2 && nTightJetsBT == 1 &&  (ht > htMin || mode !=0))  histo_R->Fill(29, xlWeight); //CR 1 
	      if (nJets == 2 && nTightJetsBT == 2 &&  (ht > htMin || mode !=0))  histo_R->Fill(30, xlWeight); //CR 2 
				
	      
	    } //jets in the event
	  } //all CR
	  
	} // mll
      } //mll pre
    } // 2 leptons
  }// event loop.
  
  
  
  if (!silent){ 
    cout << "------------------------------------------" << endl;
    cout << "[Results:] " << plotName <<  endl;
    cout << "------------------------------------------" << endl;  
    for (int i = 2; i < 9; i++){
      if (i == 2) cout << " leptons: " <<  histo->GetBinContent(i) << " +/-  " <<  histo->GetBinError(i)  << endl;
      if (i == 3) cout << " inv. mass: " <<  histo->GetBinContent(i) << " +/-  " <<  histo->GetBinError(i)  << endl;
      if (i == 4) cout << " met: " <<  histo->GetBinContent(i) << " +/-  " <<  histo->GetBinError(i)  << endl;
      if (i == 5) cout << " jet: " <<  histo->GetBinContent(i) << " +/-  " <<  histo->GetBinError(i)  << endl;
      if (i == 6) cout << " jet_bt: " <<  histo->GetBinContent(i) << " +/-  " <<  histo->GetBinError(i)  << endl;
      if (i == 7) cout << " ht: " <<  histo->GetBinContent(i) << " +/-  " <<  histo->GetBinError(i)  << endl;
    }
    cout << "------------------------------------------" << endl; 
  }
  f_var.Write();
  f_var.Close();
}