예제 #1
0
/* Init the rgb chip.
Actually, I do not need any lock her!
Because there are only least delay time, no delay limitation.
*/
int hw_requestGPIO(const rgb_chip_layout *layout) {
	int res = 0;
	Fin("CTRL:%d", layout->gpio_CTRL);
	mHW.CTRL = layout->gpio_CTRL;
	memset(mHW.reg,0, sizeof(mHW.reg));

    res = gpio_request(mHW.CTRL, "rgb_ctrl");
    if (res<0) {
        Fout("Error 4");
        return -1;
    }

	Fout("Success");
	return 1;
}
예제 #2
0
void Step1::selectProjectIcon()
{
  QString path = QFileInfo(MainWindow::instance().configFileName()).path();
  QString iconName = QFileDialog::getOpenFileName(this,
                                    tr("Select project icon/image"),path);
  if (iconName.isEmpty())
  {
    m_projIconLab->setText(tr("No Project logo selected."));
  }
  else
  {
    QFile Fout(iconName);
    if(!Fout.exists()) 
    {
      m_projIconLab->setText(tr("Sorry, cannot find file(")+iconName+QString::fromAscii(");"));
    }
    else
    {
      QPixmap pm(iconName);
      if (!pm.isNull())
      {
        m_projIconLab->setPixmap(pm.scaledToHeight(55,Qt::SmoothTransformation));
      }
      else
      {
        m_projIconLab->setText(tr("Sorry, no preview available (")+iconName+QString::fromAscii(");"));
      }
    }
  }
  updateStringOption(m_modelData,STR_PROJECT_LOGO,iconName);
}
예제 #3
0
파일: main.cpp 프로젝트: freehyan/OSG
int main()
{
    osg::ref_ptr<osgViewer::Viewer> OsgViewer = new osgViewer::Viewer;
    osg::ref_ptr<osg::Group> RootGroup = new osg::Group;
    osg::ref_ptr<osg::Node> CowNode = osgDB::readNodeFile("../OSGData/cow.osg");
    RootGroup->addChild(CowNode);

    CVertexVistor VertVistor;
    CowNode->accept(VertVistor);

    std::ofstream Fout("cow.vertexs");
    unsigned int Size = VertVistor.m_ExtractedVerts->size();

    std::vector<osg::Vec3>::iterator It = VertVistor.m_ExtractedVerts->begin();
    for (unsigned int i=0; i<Size; i++)
    {
        Fout << It->x() << " " << It->y() << " " << It->z() << " " << std::endl;
        It++;
    }

    osgUtil::Optimizer Opti;
    Opti.optimize(RootGroup.get());
    OsgViewer->setSceneData(RootGroup.get());
    OsgViewer->realize();
    OsgViewer->run();

    return 1;
}
예제 #4
0
int hw_getReg(const int REG){
	Fin();
	if (REG<0 || REG>8) {
		Ftr("No such reg:%d", (unsigned int)REG);
		return -1;
	}
	Fout("reg:%d has %X", REG, mHW.reg[REG]);
	return mHW.reg[REG];
}
예제 #5
0
int hw_sendData(
		const int  REG,
		const unsigned char data_) {
	unsigned long int_flags;

	struct timeval tv1,tv2;
	unsigned char data = data_;

	Fin();
	if (REG<0 || REG>8) {
		Ftr();
		return -1;
	}

	Ftr(" echo %d > %d", data, REG);


	if (REG == 0) {
		// 1110 0111
		data &= 0xe7;
		// To disable unstable flags, vendor suggests it.
	}

	do_gettimeofday(&tv1);
	spin_lock_irqsave(&my_lock, int_flags);
	mHW.reg[REG] = data;

	gpio_set_value(mHW.CTRL, 1);
	udelay(20); // TDS: data start. typical 10 us
	// fill the address.
	if (REG&0x08) SEND_HIGH(); else SEND_LOW();
	if (REG&0x04) SEND_HIGH(); else SEND_LOW();
	if (REG&0x02) SEND_HIGH(); else SEND_LOW();
	if (REG&0x01) SEND_HIGH(); else SEND_LOW();
	// fill the data.
	if (data&0x80) SEND_HIGH(); else SEND_LOW();
	if (data&0x40) SEND_HIGH(); else SEND_LOW();
	if (data&0x20) SEND_HIGH(); else SEND_LOW();
	if (data&0x10) SEND_HIGH(); else SEND_LOW();
    if (data&0x08) SEND_HIGH(); else SEND_LOW();
    if (data&0x04) SEND_HIGH(); else SEND_LOW();
    if (data&0x02) SEND_HIGH(); else SEND_LOW();
    if (data&0x01) SEND_HIGH(); else SEND_LOW();
	// fill EOD
	gpio_set_value(mHW.CTRL,0);
	udelay(8); //typical val: 2 us
	gpio_set_value(mHW.CTRL,1);
	udelay(400); //typical val: 350 us
	spin_unlock_irqrestore(&my_lock, int_flags);
	do_gettimeofday(&tv2);
	
	Fout("at %d, tv: (%d)us", REG, tv2.tv_usec - tv1.tv_usec);
	return 1;
}
uint32 SerialThread::Run()
{
	FPlatformProcess::Sleep(0.03);
	while (StopTaskCounter.GetValue() == 0 && SP->IsOpened())
	{
		int nBytesRead = SP->ReadData(incomingData1, 1);
		if (nBytesRead > 0)
		{
			if (len1 > 180 || incomingData1[0] == '\n')//strcmp(incomingData1, "\r") == 0 || strcmp(incomingData1, "\n") == 0 || strcmp(incomingData1, "\t") == 0 || len1 > 180)
			{
				if (strlen(outData1) > 0)
				{
					std::string test(outData1);
					FString Fout(test.c_str());
					TheBP->GetData(Fout);
					len1 = 0;
					memset(outData1, 0, sizeof outData1);
				}
			}
			else
			{
				//bool flag = false;

				//if (len1 == 0)
				//{
				//	flag = (incomingData1[0] == 's');//(strcmp(incomingData1, "s") == 0);
				//}
				//else if (len1 == 1)
				//{
				//	flag = (incomingData1[0] == 't');// (strcmp(incomingData1, "t") == 0);
				//}
				//else if (len1 == 2)
				//{
				//	flag = (incomingData1[0] == 'e');// (strcmp(incomingData1, "e") == 0);
				//}
				//else
				//	flag = true;

				//if (flag)
				//{
					outData1[len1] = incomingData1[0];
					len1++;
				//}
			
			}
		}

		FString writeData = TheBP->SendData();
		strcpy_s(writeBuffer1, TCHAR_TO_ANSI(*writeData));
		SP->SendData(writeBuffer1, strlen(writeBuffer1));
	}
	return 0;
}
예제 #7
0
파일: csv_reader.cpp 프로젝트: hanicho/vis
csv_reader::csv_reader( QString path )
    : _path( path ), _instream( path.toStdString().c_str() ), _bad_path(false)
{

    //  Does the file exist?!
    //
    QFile Fout(path);

    if(!Fout.exists()){
        _bad_path=true;
        helpers::debug_error( "path does not exist...", "csv reader", path );
    }
}
예제 #8
0
void Step1::init()
{
  Input *option;
  m_projName->setText(getStringOption(m_modelData,STR_PROJECT_NAME));
  m_projBrief->setText(getStringOption(m_modelData,STR_PROJECT_BRIEF));
  m_projNumber->setText(getStringOption(m_modelData,STR_PROJECT_NUMBER));
  QString iconName = getStringOption(m_modelData,STR_PROJECT_LOGO);
  if (!iconName.isEmpty())
  {
    QFile Fout(iconName);
    if(!Fout.exists()) 
    {
      m_projIconLab->setText(tr("Sorry, cannot find file(")+iconName+QString::fromAscii(");"));
    }
    else
    {
      QPixmap pm(iconName);
      if (!pm.isNull())
      {
        m_projIconLab->setPixmap(pm.scaledToHeight(55,Qt::SmoothTransformation));
      }
      else
      {
        m_projIconLab->setText(tr("Sorry, no preview available (")+iconName+QString::fromAscii(");"));
      }
    }
  }
  else
  {
    m_projIconLab->setText(tr("No Project logo selected."));
  }
  option = m_modelData[STR_INPUT];
  if (option->value().toStringList().count()>0)
  {
    m_sourceDir->setText(option->value().toStringList().first());
  }
  m_recursive->setChecked(
      getBoolOption(m_modelData,STR_RECURSIVE) ? Qt::Checked : Qt::Unchecked);
  m_destDir->setText(getStringOption(m_modelData,STR_OUTPUT_DIRECTORY));
}
예제 #9
0
int hw_wakeup(void) {
	unsigned long int_flags;
    struct timeval tv1,tv2;
	//long artv[3];
	Fin();
	do_gettimeofday(&tv1);

    spin_lock_irqsave(&my_lock, int_flags);
	
	udelay(200);
	gpio_set_value(mHW.CTRL, 1);
	udelay(100);
	
    gpio_set_value(mHW.CTRL, 0); //min: 10 us
	udelay(15);

    gpio_set_value(mHW.CTRL, 1); //min: 400 us, max:600 us
	udelay(450);

	spin_unlock_irqrestore(&my_lock, int_flags);
	do_gettimeofday(&tv2);
	Fout("tv:%d", tv2.tv_usec - tv1.tv_usec);
	return 0;
}
//------------------------------------------------------------------------------
// LatinosTreeScript
//------------------------------------------------------------------------------
void LatinosTreeScript_dcap_WgStarSel_v3_EpTCorr(Float_t luminosity,
		Int_t   jetChannel,
		TString flavorChannel,
		TString theSample,
		TString  TypeStudy="Nominal",
		Bool_t  verbose=true)
{
  TH1::SetDefaultSumw2();

  // Set the channel
  //----------------------------------------------------------------------------
  Float_t SelectedChannel = -999;
  
  if      (flavorChannel == "MuMu") SelectedChannel =  0;
  else if (flavorChannel == "EE"  ) SelectedChannel =  1;
  else if (flavorChannel == "EMu" ) SelectedChannel =  2;
  else if (flavorChannel == "MuE" ) SelectedChannel =  3;
  else if (flavorChannel == "All" ) SelectedChannel = -1;
  else if (flavorChannel == "SSEMuPlus"  ) SelectedChannel =  2; //Channel is the same
  else if (flavorChannel == "SSEMuMinus" ) SelectedChannel =  2;
  else if (flavorChannel == "SSMuEPlus"  ) SelectedChannel =  3;
  else if (flavorChannel == "SSMuEMinus" ) SelectedChannel =  3;

  enum TYPeSTUDY {Nominal, GenStudy};
  int SelectedStudy;
  cout<<"TypeStudy: "<<TypeStudy<<endl;
  if      (TypeStudy == "GenStudy") SelectedStudy = GenStudy;
  else if (TypeStudy == "Nominal")  SelectedStudy = Nominal;
  else                              SelectedStudy = Nominal;

  bool MuonPtCut(false);

  cout<<"Study Type is "<<SelectedStudy<<endl;
 
  // OutPut 
  //-------------------------------------------------
  TString path = Form("rootfiles/%djet/%s/", jetChannel, flavorChannel.Data());
  //TString path = Form("rootfiles_WgIso_mll_110_met25pt30103/%djet/%s/", jetChannel, flavorChannel.Data());
  gSystem->mkdir(path, kTRUE);
  
  TFile* output = new TFile(path + theSample + ".root", "recreate");
  TString NameFout=path + theSample +".txt";
  ofstream Fout(NameFout);


  // Histograms
  //----------------------------------------------------------------------------
  
  TH1D*   hGen_mll   = new TH1D("hGen_mll","hGen_mll",55,0,110);
  TH1D*   hInvDimu_Recon = new TH1D("hInvDimu_Recon","hInvDimu_Recon",55,0,110);
  TH1D*   hInvDimu_Gen   = new TH1D("hInvDimu_Gen","hInvDimu_Gen",55,0,110); 
  TH1D*   hInvDimu_Gen_All=new TH1D("hInvDimu_Gen_All","hInvDimu_Gen_All",100,0,20); 
  TH1D*   hNmuons   = new TH1D("hNmuons","hNmuons",5,0,5); 
  TH1D*   hTriMuOrder   = new TH1D("hTriMuOrder","hTriMuOrder",5,0,10); 
  TH1D*   hMu1_pt   = new TH1D("hMu1_pt","hMu1_pt",5,0,50); 
  TH1D*   hMu2_pt   = new TH1D("hMu2_pt","hMu2_pt",5,0,50); 
  TH1D*   hMu3_pt   = new TH1D("hMu3_pt","hMu3_pt",5,0,50); 
  
  //for (UInt_t i=0; i<nLevels; i++) {
  //	hPtLepton1      [i] = new TH1F("hPtLepton1"       + sLevel[i], "", 200, 0, 200);
  //	hPtLepton2      [i] = new TH1F("hPtLepton2"       + sLevel[i], "", 200, 0, 200);
  //}
  
  
  // Data-driven methods: Z+jets
  //----------------------------------------------------------------------------

  
  // Data-driven methods:
  //----------------------------------------------------------------------------
  //----------------------------------------------------------------------------
  // Input files
  //----------------------------------------------------------------------------
  TString filesPath;
  
  
  if (runAtLxplus) filesPath = "~/eos_cernbox/user/r/rebeca/HWW2015/";
  else             filesPath = "dcap://cluster142.knu.ac.kr//pnfs/knu.ac.kr/data/cms/store/user/spak/CernBox_Rebeca/";
  //else             filesPath = "/u/user/sangilpark/RunIIData/cernboxHWW76X/";
  //if (runAtOviedo) filesPath = "root://eoscms.cern.ch//eos/cms/store/user/yjcho/nTuple/";
  //else             filesPath = "root://eoscms.cern.ch//eos/cms/store/user/yjcho/nTuple/";
  TChain* tree = new TChain("latino", "latino");
  
  // l2sel
  if (theSample == "DataRun2015") {
  	tree->Add(filesPath + "03Mar_Run2015C_16Dec2015/WgStarsel__hadd__EpTCorr/" + "latino_Run2015C_16Dec2015_SingleMuon.root");
  	tree->Add(filesPath + "03Mar_Run2015D_16Dec2015/WgStarsel__hadd__EpTCorr/" + "latino_Run2015D_16Dec2015_SingleMuon.root");
  	//tree->Add(filesPath + "03Mar_Run2015C_16Dec2015/WgStarsel__hadd__EpTCorr/" + "latino_Run2015C_16Dec2015_SingleElectron.root");
  	//tree->Add(filesPath + "03Mar_Run2015D_16Dec2015/WgStarsel__hadd__EpTCorr/" + "latino_Run2015D_16Dec2015_SingleElectron.root");
  }else if (theSample == "DataRun2015_C") {
  	tree->Add(filesPath + "03Mar_Run2015C_16Dec2015/WgStarsel__hadd__EpTCorr/" + "latino_Run2015C_16Dec2015_SingleMuon.root");
  	//tree->Add(filesPath + "03Mar_Run2015C_16Dec2015/WgStarsel__hadd__EpTCorr/" + "latino_Run2015C_16Dec2015_SingleElectron.root");
  }else if (theSample == "DataRun2015_D") {
  	tree->Add(filesPath + "03Mar_Run2015D_16Dec2015/WgStarsel__hadd__EpTCorr/" + "latino_Run2015D_16Dec2015_SingleMuon.root");
  	//tree->Add(filesPath + "03Mar_Run2015D_16Dec2015/WgStarsel__hadd__EpTCorr/" + "latino_Run2015D_16Dec2015_SingleElectron.root");
  }
  else if (theSample == "WJetsLNu") {
    if (runAtLxplus) tree->Add("~/eos_cernbox/user/j/jlauwers/HWW2015/22Jan_25ns_mAODv2_MC/MCl2loose__hadd/latino_WJetsToLNu.root");
    else tree->Add("dcap://cluster142.knu.ac.kr//pnfs/knu.ac.kr/data/cms/store/user/spak/cernboxHWW76X/22Jan_25ns_mAODv2_MC/MCl2loose__hadd/latino_WJetsToLNu.root");
  }
  else if (theSample == "WJetsLNu_HT") { 
    if (runAtLxplus)
    {
  	tree->Add("~/eos_cernbox/user/j/jlauwers/HWW2015/22Jan_25ns_mAODv2_MC/MCl2loose__hadd/latino_WJetsToLNu_HT100_200.root");
  	tree->Add("~/eos_cernbox/user/j/jlauwers/HWW2015/22Jan_25ns_mAODv2_MC/MCl2loose__hadd/latino_WJetsToLNu_HT200_400.root");
  	tree->Add("~/eos_cernbox/user/j/jlauwers/HWW2015/22Jan_25ns_mAODv2_MC/MCl2loose__hadd/latino_WJetsToLNu_HT400_600.root");
  	tree->Add("~/eos_cernbox/user/j/jlauwers/HWW2015/22Jan_25ns_mAODv2_MC/MCl2loose__hadd/latino_WJetsToLNu_HT600_800.root");
  	tree->Add("~/eos_cernbox/user/j/jlauwers/HWW2015/22Jan_25ns_mAODv2_MC/MCl2loose__hadd/latino_WJetsToLNu_HT800_1200.root");
  	tree->Add("~/eos_cernbox/user/j/jlauwers/HWW2015/22Jan_25ns_mAODv2_MC/MCl2loose__hadd/latino_WJetsToLNu_HT1200_2500.root");
  	tree->Add("~/eos_cernbox/user/j/jlauwers/HWW2015/22Jan_25ns_mAODv2_MC/MCl2loose__hadd/latino_WJetsToLNu_HT2500_inf.root");
    }
    else
    {
  	tree->Add("dcap://cluster142.knu.ac.kr//pnfs/knu.ac.kr/data/cms/store/user/spak/cernboxHWW76X/22Jan_25ns_mAODv2_MC/MCl2loose__hadd/latino_WJetsToLNu_HT100_200.root");
  	tree->Add("dcap://cluster142.knu.ac.kr//pnfs/knu.ac.kr/data/cms/store/user/spak/cernboxHWW76X/22Jan_25ns_mAODv2_MC/MCl2loose__hadd/latino_WJetsToLNu_HT200_400.root");
  	tree->Add("dcap://cluster142.knu.ac.kr//pnfs/knu.ac.kr/data/cms/store/user/spak/cernboxHWW76X/22Jan_25ns_mAODv2_MC/MCl2loose__hadd/latino_WJetsToLNu_HT400_600.root");
  	tree->Add("dcap://cluster142.knu.ac.kr//pnfs/knu.ac.kr/data/cms/store/user/spak/cernboxHWW76X/22Jan_25ns_mAODv2_MC/MCl2loose__hadd/latino_WJetsToLNu_HT600_800.root");
  	tree->Add("dcap://cluster142.knu.ac.kr//pnfs/knu.ac.kr/data/cms/store/user/spak/cernboxHWW76X/22Jan_25ns_mAODv2_MC/MCl2loose__hadd/latino_WJetsToLNu_HT800_1200.root");
  	tree->Add("dcap://cluster142.knu.ac.kr//pnfs/knu.ac.kr/data/cms/store/user/spak/cernboxHWW76X/22Jan_25ns_mAODv2_MC/MCl2loose__hadd/latino_WJetsToLNu_HT1200_2500.root");
  	tree->Add("dcap://cluster142.knu.ac.kr//pnfs/knu.ac.kr/data/cms/store/user/spak/cernboxHWW76X/22Jan_25ns_mAODv2_MC/MCl2loose__hadd/latino_WJetsToLNu_HT2500_inf.root");
    }
  }
  else if (theSample == "ggWWto2L") {
  	tree->Add(filesPath + "22Jan_25ns_mAODv2_MC/MCl2loose__hadd__bSFL2pTEff__l2tight/" + "latino_GluGluWWTo2L2Nu_MCFM.root");
  }
  else if (theSample == "WWTo2L2Nu") {
  	tree->Add(filesPath + "22Jan_25ns_mAODv2_MC/MCl2loose__hadd__bSFL2pTEff__l2tight/" + "latino_WWTo2L2Nu.root");
  }
  else if (theSample == "WZ") {
  	//tree->Add(filesPath + "22Jan_25ns_mAODv2_MC/MCl2loose__hadd/" + "latino_WZ.root");
  	if (runAtLxplus) tree->Add("~/eos_cernbox/user/j/jlauwers/HWW2015/22Jan_25ns_mAODv2_MC/MCl2loose__hadd/latino_WZJets.root");
  	else tree->Add("dcap://cluster142.knu.ac.kr//pnfs/knu.ac.kr/data/cms/store/user/spak/cernboxHWW76X/22Jan_25ns_mAODv2_MC/MCl2loose__hadd/latino_WZJets.root");
  }
  else if (theSample == "WZ2Q") {
  	tree->Add(filesPath + "22Jan_25ns_mAODv2_MC/MCWgStarsel__hadd__EpTCorr/" + "latino_WZTo2L2Q__part1.root");
  	tree->Add(filesPath + "22Jan_25ns_mAODv2_MC/MCWgStarsel__hadd__EpTCorr/" + "latino_WZTo2L2Q__part2.root");
  	tree->Add(filesPath + "22Jan_25ns_mAODv2_MC/MCWgStarsel__hadd__EpTCorr/" + "latino_WZTo2L2Q__part3.root");
  	tree->Add(filesPath + "22Jan_25ns_mAODv2_MC/MCWgStarsel__hadd__EpTCorr/" + "latino_WZTo2L2Q__part4.root");
  	tree->Add(filesPath + "22Jan_25ns_mAODv2_MC/MCWgStarsel__hadd__EpTCorr/" + "latino_WZTo2L2Q__part5.root");
  }
  else if (theSample == "WZ3LNu") {
  	tree->Add(filesPath + "22Jan_25ns_mAODv2_MC/MCWgStarsel__hadd__EpTCorr/" + "latino_WZTo3LNu.root");
  }
  else if (theSample == "ZZ") {
  	tree->Add(filesPath + "22Jan_25ns_mAODv2_MC/MCl2loose__hadd__bSFL2pTEff__l2tight/" + "latino_ZZ.root");
  	tree->Add(filesPath + "22Jan_25ns_mAODv2_MC/MCl2loose__hadd__bSFL2pTEff__l2tight/" + "latino_ZZTo4L.root");
  	tree->Add(filesPath + "22Jan_25ns_mAODv2_MC/MCl2loose__hadd__bSFL2pTEff__l2tight/" + "latino_ZZTo2L2Nu.root");
  	tree->Add(filesPath + "22Jan_25ns_mAODv2_MC/MCl2loose__hadd__bSFL2pTEff__l2tight/" + "latino_ZZTo2L2Q_0000__part0.root");
  	tree->Add(filesPath + "22Jan_25ns_mAODv2_MC/MCl2loose__hadd__bSFL2pTEff__l2tight/" + "latino_ZZTo2L2Q_0000__part1.root");
  	tree->Add(filesPath + "22Jan_25ns_mAODv2_MC/MCl2loose__hadd__bSFL2pTEff__l2tight/" + "latino_ZZTo2L2Q_0000__part2.root");
  	tree->Add(filesPath + "22Jan_25ns_mAODv2_MC/MCl2loose__hadd__bSFL2pTEff__l2tight/" + "latino_ZZTo2L2Q_0000__part3.root");
  	tree->Add(filesPath + "22Jan_25ns_mAODv2_MC/MCl2loose__hadd__bSFL2pTEff__l2tight/" + "latino_ZZTo2L2Q_0000__part4.root");
  	tree->Add(filesPath + "22Jan_25ns_mAODv2_MC/MCl2loose__hadd__bSFL2pTEff__l2tight/" + "latino_ZZTo2L2Q_0001__part0.root");
  	tree->Add(filesPath + "22Jan_25ns_mAODv2_MC/MCl2loose__hadd__bSFL2pTEff__l2tight/" + "latino_ZZTo2L2Q_0001__part1.root");
  	tree->Add(filesPath + "22Jan_25ns_mAODv2_MC/MCl2loose__hadd__bSFL2pTEff__l2tight/" + "latino_ZZTo2L2Q_0001__part2.root");
  }
  else if (theSample == "TTbar") {
  	tree->Add(filesPath + "22Jan_25ns_mAODv2_MC/MCl2loose__hadd__bSFL2pTEff__l2tight/" + "latino_TTTo2L2Nu.root");
  }
  else if (theSample == "TW") {
  	tree->Add(filesPath + "22Jan_25ns_mAODv2_MC/MCl2loose__hadd__bSFL2pTEff__l2tight/" + "latino_ST_tW_antitop.root");
  	tree->Add(filesPath + "22Jan_25ns_mAODv2_MC/MCl2loose__hadd__bSFL2pTEff__l2tight/" + "latino_ST_tW_top.root");
  }
  else if (theSample == "DY") {
  	tree->Add(filesPath + "22Jan_25ns_mAODv2_MC/MCl2loose__hadd__bSFL2pTEff__l2tight/" + "latino_DYJetsToLL_M-10to50.root"); // buggy
  	tree->Add(filesPath + "22Jan_25ns_mAODv2_MC/MCl2loose__hadd__bSFL2pTEff__l2tight/" + "latino_DYJetsToLL_M-10to50ext3.root");
  	tree->Add(filesPath + "22Jan_25ns_mAODv2_MC/MCl2loose__hadd__bSFL2pTEff__l2tight/" + "latino_DYJetsToLL_M-50_0000__part0.root");
  	tree->Add(filesPath + "22Jan_25ns_mAODv2_MC/MCl2loose__hadd__bSFL2pTEff__l2tight/" + "latino_DYJetsToLL_M-50_0000__part1.root");
  	tree->Add(filesPath + "22Jan_25ns_mAODv2_MC/MCl2loose__hadd__bSFL2pTEff__l2tight/" + "latino_DYJetsToLL_M-50_0000__part2.root");
  	//tree->Add(filesPath + "22Jan_25ns_mAODv2_MC/MCl2loose__hadd__bSFL2pTEff__l2tight/" + "latino_DYJetsToLL_M-50_0000__part3.root");
  	tree->Add(filesPath + "22Jan_25ns_mAODv2_MC/MCl2loose__hadd__bSFL2pTEff__l2tight/" + "latino_DYJetsToLL_M-50_0000__part4.root");
  	tree->Add(filesPath + "22Jan_25ns_mAODv2_MC/MCl2loose__hadd__bSFL2pTEff__l2tight/" + "latino_DYJetsToLL_M-50_0001__part0.root");
  	tree->Add(filesPath + "22Jan_25ns_mAODv2_MC/MCl2loose__hadd__bSFL2pTEff__l2tight/" + "latino_DYJetsToLL_M-50_0001__part1.root");
  	tree->Add(filesPath + "22Jan_25ns_mAODv2_MC/MCl2loose__hadd__bSFL2pTEff__l2tight/" + "latino_DYJetsToLL_M-50_0001__part2.root");
  	tree->Add(filesPath + "22Jan_25ns_mAODv2_MC/MCl2loose__hadd__bSFL2pTEff__l2tight/" + "latino_DYJetsToLL_M-50_0001__part3.root");
  	//tree->Add(filesPath + "22Jan_25ns_mAODv2_MC/MCl2loose__hadd__bSFL2pTEff__l2tight/" + "latino_DYJetsToLL_M-50_0001__part4.root");
  	tree->Add(filesPath + "22Jan_25ns_mAODv2_MC/MCl2loose__hadd__bSFL2pTEff__l2tight/" + "latino_DYJetsToLL_M-50_0002__part0.root");
  	//tree->Add(filesPath + "22Jan_25ns_mAODv2_MC/MCl2loose__hadd__bSFL2pTEff__l2tight/" + "latino_DYJetsToLL_M-50-LO__part0.root");
  	//tree->Add(filesPath + "22Jan_25ns_mAODv2_MC/MCl2loose__hadd__bSFL2pTEff__l2tight/" + "latino_DYJetsToLL_M-50-LO__part1.root");
  }
  else if (theSample == "DYtautau") {
  	//tree->Add("/afs/cern.ch/work/x/xjanssen/public/LatinoTrees/R53X_S1_V08_S2_V09_S3_V13/MoriondeffWPuWtriggW/TauTau_btagvar/latino_DYtt_19.5fb.root");
  	//tree->Add(filesPath + "latino_DYtt_19.5fb.root");
  }
  else if (theSample == "WgammaNoStar") {
  	tree->Add(filesPath + "22Jan_25ns_mAODv2_MC/MCWgStarsel__hadd__EpTCorr/" + "latino_Wg_AMCNLOFXFX.root");
  }
  else if (theSample == "WgammaStarToLNuMuMu") {
  	tree->Add(filesPath + "22Jan_25ns_mAODv2_MC/MCWgStarsel__hadd__EpTCorr/" + "latino_WgStarLNuMuMu.root");
  }
  else if (theSample == "WgammaStarToLNuEE") {
  	tree->Add(filesPath + "22Jan_25ns_mAODv2_MC/MCWgStarsel__hadd__EpTCorr/" + "latino_WgStarLNuEE.root");
  }
  else if (theSample == "HWW125") { 
  	tree->Add(filesPath + "22Jan_25ns_mAODv2_MC/MCl2loose__hadd__bSFL2pTEff__l2tight/" + "latino_GluGluHToWWTo2L2Nu_M125.root");
  	//tree->Add(filesPath + "22Jan_25ns_mAODv2_MC/MCl2loose__hadd__bSFL2pTEff__l2tight/" + "latino_GluGluHToWWTo2L2Nu_alternative_M125.root");
  	//tree->Add(filesPath + "22Jan_25ns_mAODv2_MC/MCl2loose__hadd__bSFL2pTEff__l2tight/" + "latino_GluGluHToWWTo2L2NuPowheg_M125.root");
  	//tree->Add(filesPath + "22Jan_25ns_mAODv2_MC/MCl2loose__hadd__bSFL2pTEff__l2tight/" + "latino_GluGluHToWWTo2L2NuHerwigPS_M125.root");
  	tree->Add(filesPath + "22Jan_25ns_mAODv2_MC/MCl2loose__hadd__bSFL2pTEff__l2tight/" + "latino_GluGluHToTauTau_M125.root");
  	
	tree->Add(filesPath + "22Jan_25ns_mAODv2_MC/MCl2loose__hadd__bSFL2pTEff__l2tight/" + "latino_VBFHToTauTau_M125.root");
	tree->Add(filesPath + "22Jan_25ns_mAODv2_MC/MCl2loose__hadd__bSFL2pTEff__l2tight/" + "latino_VBFHToWWTo2L2Nu_M125.root");
	//tree->Add(filesPath + "22Jan_25ns_mAODv2_MC/MCl2loose__hadd__bSFL2pTEff__l2tight/" + "latino_VBFHToWWTo2L2Nu_HerwigPS_M125.root");
	//tree->Add(filesPath + "22Jan_25ns_mAODv2_MC/MCl2loose__hadd__bSFL2pTEff__l2tight/" + "latino_VBFHToWWTo2L2Nu_alternative_M125.root");
  }
  else if (theSample == "Zgamma") { 
	tree->Add(filesPath + "22Jan_25ns_mAODv2_MC/MCl2loose__hadd__bSFL2pTEff__l2tight/" + "latino_Zg.root");
  }
  else {
        cout<<"Check theSample name, exiting......................."<<endl;
  	return;
  }
 
  //----------------------------------------------------------------------------
  // Input files End
  //----------------------------------------------------------------------------


  // Declaration of leaf types
  //----------------------------------------------------------------------------
  tree->SetBranchAddress("baseW",        &baseW);
  tree->SetBranchAddress("puW",      &puW);
  tree->SetBranchAddress("channel",      &channel);
  //tree->SetBranchAddress("Gen_ZGstar_deltaR",      &Gen_ZGstar_deltaR);
  tree->SetBranchAddress("Gen_ZGstar_mass",        &Gen_ZGstar_mass);
  //tree->SetBranchAddress("Gen_ZGstar_mu1_eta",     &Gen_ZGstar_mu1_eta);
  //tree->SetBranchAddress("Gen_ZGstar_mu1_phi",     &Gen_ZGstar_mu1_phi);
  //tree->SetBranchAddress("Gen_ZGstar_mu1_pt",      &Gen_ZGstar_mu1_pt);
  //tree->SetBranchAddress("Gen_ZGstar_mu2_eta",     &Gen_ZGstar_mu2_eta);
  //tree->SetBranchAddress("Gen_ZGstar_mu2_phi",     &Gen_ZGstar_mu2_phi);
  //tree->SetBranchAddress("Gen_ZGstar_mu2_pt",      &Gen_ZGstar_mu2_pt);
  tree->SetBranchAddress("std_vector_lepton_flavour", &std_vector_lepton_flavour);
  tree->SetBranchAddress("std_vector_lepton_pt", &std_vector_lepton_pt);
  tree->SetBranchAddress("std_vector_lepton_phi",&std_vector_lepton_phi);
  tree->SetBranchAddress("std_vector_lepton_eta",&std_vector_lepton_eta);
  tree->SetBranchAddress("std_vector_lepton_eleIdTight",&std_vector_lepton_eleIdTight);
  tree->SetBranchAddress("std_vector_lepton_photonIso", &std_vector_lepton_photonIso);
  tree->SetBranchAddress("std_vector_lepton_neutralHadronIso", &std_vector_lepton_neutralHadronIso);
  tree->SetBranchAddress("std_vector_lepton_sumPUPt",          &std_vector_lepton_sumPUPt);
  tree->SetBranchAddress("std_vector_lepton_isMediumMuon",    &std_vector_lepton_isMediumMuon);
  tree->SetBranchAddress("std_vector_lepton_d0",    &std_vector_lepton_d0);
  tree->SetBranchAddress("std_vector_lepton_dz",    &std_vector_lepton_dz);
  tree->SetBranchAddress("njet",         &njet);
  tree->SetBranchAddress("nbjettche",    &nbjettche);
  tree->SetBranchAddress("nbjet",        &nbjet);
  tree->SetBranchAddress("mpmet",        &mpmet);
  tree->SetBranchAddress("metPfType1",          &metPfType1);
  //tree->SetBranchAddress("bveto_mu",        &bveto_mu);
  tree->SetBranchAddress("bveto_ip",        &bveto_ip);
  if(theSample.Contains("WJetsFakes"))
    tree->SetBranchAddress("fakeW", &fakeW);

  if( SelectedStudy== GenStudy){
    tree->SetBranchAddress("gen_mll",          &gen_mll);
  }else{
    tree->SetBranchAddress("mth",          &mth);
    tree->SetBranchAddress("std_vector_lepton_isLooseLepton",    &std_vector_lepton_isLooseLepton);
    tree->SetBranchAddress("std_vector_lepton_isTightLepton",    &std_vector_lepton_isTightLepton);
    tree->SetBranchAddress("std_vector_lepton_isWgsLepton",    &std_vector_lepton_isWgsLepton);
  }

  
  
  //if (!theSample.Contains("WJetsFakes") && !theSample.Contains("Data"))
  //	tree->SetBranchAddress("puW", &puW);
  
  
  
  //----------------------------------------------------------------------------
  // Loop
  //----------------------------------------------------------------------------
  std::vector<TLorentzVector> *vMuon_4d_rec;
  std::vector<TLorentzVector> *vMuon_4d_gen;
  std::vector<int> *vMuon_Flv_rec;
  std::vector<int> *vMuon_isWgsLepton_rec;
  std::vector<int> *vMuon_isTightLepton_rec;
  std::vector<int> *vMuon_isLooseLepton_rec;
  std::vector<int> *vMuon_Flv_gen;

  vMuon_4d_rec  = new std::vector<TLorentzVector>;
  vMuon_4d_gen  = new std::vector<TLorentzVector>;
  vMuon_Flv_rec = new std::vector<int>;
  vMuon_isWgsLepton_rec = new std::vector<int>;
  vMuon_isTightLepton_rec = new std::vector<int>;
  vMuon_isLooseLepton_rec = new std::vector<int>;
  vMuon_Flv_gen   = new std::vector<int>;
  int iLept;
  double lepton_pt, lepton_eta, lepton_phi, lepton_flv;
  double lepton_isWgsLepton, lepton_isTightLepton, lepton_isLooseLepton;
  
  TLorentzVector muon4d;
  int MuonPtOrder;

  //Cuts=======================
  struct Cuts{
    const double firstMu=30;
    const double secndMu=10;
    const double thirdMu=3;
  }Cuts;

  int TotNtry=tree->GetEntries();
  //TotNtry=500;
  cout<<"Total number of event to process: "<<TotNtry<<endl;

  //for (int ievent=0; ievent<TotNtry; ievent++) {
  for (int ievent=0; ievent<10000; ievent++) {
    if(ievent%100000 ==0) cout<<"Processing "<<ievent<<"th event"<<endl; 

    // initialize
    vMuon_4d_rec->clear();
    vMuon_4d_gen->clear();
    vMuon_Flv_rec->clear();
    vMuon_isWgsLepton_rec->clear();
    vMuon_isTightLepton_rec->clear();
    vMuon_isLooseLepton_rec->clear();
    vMuon_Flv_gen->clear();

    MuonPtOrder=0;
    //vMuon_4d_rec=0;
    // dump variable
    tree->GetEntry(ievent);
    //cout<<" baseW: "<<baseW<<"\t"<<"channel: "<<channel<<endl;
    //cout<<"Lepton flavor:          pt"<<endl;
    //for(int iLept(0); iLept<std_vector_lepton_flavour->size();iLept++)
    //{
    //}
    iLept=0;

    // Weight Calc.
    //
    //
    totalW      = -999;

    if (theSample.Contains("Data"))
    {
    	//totalW = baseW;
    	totalW = 1.0;
    }
    else if (theSample.Contains("WZ") || theSample.Contains("HWW125"))
    {
    	totalW = baseW * puW* luminosity;
    	//totalW = fakeW;
    }
    else
    {
    	//efficiencyW = puW * effW * triggW;
    
    	//totalW = (1 + 0.6 * (dataset >= 82 && dataset <= 84)) * baseW * efficiencyW * luminosity;
    	totalW = baseW * puW* luminosity;
    	//totalW = baseW * puW* GEN_weight_SM/abs(GEN_weight_SM)* luminosity;
    }

    while((*std_vector_lepton_flavour)[iLept] >-9999)
    {
      lepton_flv  = (*std_vector_lepton_flavour)[iLept];
      lepton_pt   = (*std_vector_lepton_pt)[iLept];
      lepton_eta  = (*std_vector_lepton_eta)[iLept];
      lepton_phi  = (*std_vector_lepton_phi)[iLept];
      if(TypeStudy == "Nominal")
      {
        lepton_isWgsLepton  = (*std_vector_lepton_isWgsLepton)[iLept];
        lepton_isTightLepton  = (*std_vector_lepton_isTightLepton)[iLept];
        lepton_isLooseLepton  = (*std_vector_lepton_isLooseLepton)[iLept];
      }
      //cout<<iLept<<"\t"<<lepton_flv<<
      //  "\t"<<lepton_pt<<"\t"<<lepton_eta<<"\t"<<lepton_phi<<" isWgsLepton:"<<lepton_isWgsLepton<<" isTightLepton: "<<lepton_isTightLepton<<endl;
      if(fabs(lepton_flv) ==13)
      {
        muon4d.SetPtEtaPhiM(lepton_pt,lepton_eta,lepton_phi,M_Muon);
        vMuon_4d_rec->push_back(muon4d);
        vMuon_Flv_rec->push_back(lepton_flv);
	if(TypeStudy == "Nominal")
	{
          vMuon_isWgsLepton_rec->push_back(lepton_isWgsLepton);
          vMuon_isTightLepton_rec->push_back(lepton_isTightLepton);
          vMuon_isLooseLepton_rec->push_back(lepton_isLooseLepton);
	}
      }
      iLept++;

    }


    // Fill gen info
    // -----------------------------------
    if(!theSample.Contains("Data"))
    {
      hGen_mll->Fill(gen_mll);
      hInvDimu_Gen_All->Fill(Gen_ZGstar_mass);
      //cout<<"Gen_ZGstar_mass: "<<Gen_ZGstar_mass<<endl;
    }


    int Nmuon = vMuon_4d_rec->size();
    hNmuons->Fill(Nmuon,totalW);
    if(Nmuon < 3)continue;

    // Cuts
    // --------------------------------------------
    //cout<<"Nmuon: "<<Nmuon<<endl;
    MuonPtCut=false;
    // b-jet cut
    //cout<<"nbjettche: "<<nbjettche<<"  bveto_ip: "<<bveto_ip<<" njet: "<<njet<<" mpmet: "<<mpmet<<" mth: "<<mth<<"  metPfType1: "<<metPfType1<<endl;
    if(nbjettche !=0 )continue;
    //if(bveto_mu !=1 )continue;
    //if(bveto_ip !=1 )continue;
    if(njet > 1 )continue;

    // low mas resonance veto
    //if(mpmet < 20 )continue;
    if(metPfType1 < 25 )continue;
    //if(mth < 25 )continue;

    if( (*vMuon_4d_rec)[0].Pt() >=(*vMuon_4d_rec)[1].Pt() )
    if( (*vMuon_4d_rec)[1].Pt() >=(*vMuon_4d_rec)[2].Pt() )
    if( (*vMuon_4d_rec)[0].Pt() > Cuts.firstMu && (*vMuon_4d_rec)[1].Pt() > Cuts.secndMu && (*vMuon_4d_rec)[2].Pt() > Cuts.thirdMu)
    {
      MuonPtCut = true;
      hTriMuOrder->Fill(1,totalW);
      hMu1_pt->Fill((*vMuon_4d_rec)[0].Pt(),totalW);
      hMu2_pt->Fill((*vMuon_4d_rec)[1].Pt(),totalW);
      hMu3_pt->Fill((*vMuon_4d_rec)[2].Pt(),totalW);
    }

    if( (*vMuon_4d_rec)[0].Pt() >=(*vMuon_4d_rec)[1].Pt() )
    if( (*vMuon_4d_rec)[2].Pt() >=(*vMuon_4d_rec)[1].Pt() )
    if( (*vMuon_4d_rec)[0].Pt() >=(*vMuon_4d_rec)[2].Pt() )
    if( (*vMuon_4d_rec)[0].Pt() > Cuts.firstMu && (*vMuon_4d_rec)[2].Pt() > Cuts.secndMu && (*vMuon_4d_rec)[1].Pt() > Cuts.thirdMu)
    {
      MuonPtCut = true;
      hTriMuOrder->Fill(2,totalW);
      hMu1_pt->Fill((*vMuon_4d_rec)[0].Pt(),totalW);
      hMu2_pt->Fill((*vMuon_4d_rec)[2].Pt(),totalW);
      hMu3_pt->Fill((*vMuon_4d_rec)[1].Pt(),totalW);
    }
    if( (*vMuon_4d_rec)[0].Pt() >=(*vMuon_4d_rec)[1].Pt() )
    if( (*vMuon_4d_rec)[2].Pt() >=(*vMuon_4d_rec)[1].Pt() )
    if( (*vMuon_4d_rec)[2].Pt() >=(*vMuon_4d_rec)[0].Pt() )
    if( (*vMuon_4d_rec)[2].Pt() > Cuts.firstMu && (*vMuon_4d_rec)[0].Pt() > Cuts.secndMu && (*vMuon_4d_rec)[1].Pt() > Cuts.thirdMu)
    {
      MuonPtCut = true;
      hTriMuOrder->Fill(3,totalW);
      hMu1_pt->Fill((*vMuon_4d_rec)[2].Pt(),totalW);
      hMu2_pt->Fill((*vMuon_4d_rec)[0].Pt(),totalW);
      hMu3_pt->Fill((*vMuon_4d_rec)[1].Pt(),totalW);
    }
    if( (*vMuon_4d_rec)[1].Pt() >=(*vMuon_4d_rec)[0].Pt() )
    if( (*vMuon_4d_rec)[2].Pt() >=(*vMuon_4d_rec)[0].Pt() )
    if( (*vMuon_4d_rec)[2].Pt() >=(*vMuon_4d_rec)[1].Pt() )
    if( (*vMuon_4d_rec)[2].Pt() > Cuts.firstMu && (*vMuon_4d_rec)[1].Pt() > Cuts.secndMu  && (*vMuon_4d_rec)[0].Pt() > Cuts.thirdMu)
    {
      MuonPtCut = true;
      hTriMuOrder->Fill(4,totalW);
      hMu1_pt->Fill((*vMuon_4d_rec)[2].Pt(),totalW);
      hMu2_pt->Fill((*vMuon_4d_rec)[1].Pt(),totalW);
      hMu3_pt->Fill((*vMuon_4d_rec)[0].Pt(),totalW);
    }
    if( (*vMuon_4d_rec)[1].Pt() >=(*vMuon_4d_rec)[0].Pt() )
    if( (*vMuon_4d_rec)[2].Pt() >=(*vMuon_4d_rec)[0].Pt() )
    if( (*vMuon_4d_rec)[1].Pt() >=(*vMuon_4d_rec)[2].Pt() )
    if( (*vMuon_4d_rec)[1].Pt() > Cuts.firstMu && (*vMuon_4d_rec)[2].Pt() > Cuts.secndMu && (*vMuon_4d_rec)[0].Pt() > Cuts.thirdMu)
    {
      MuonPtCut = true;
      hTriMuOrder->Fill(5,totalW);
      hMu1_pt->Fill((*vMuon_4d_rec)[1].Pt(),totalW);
      hMu2_pt->Fill((*vMuon_4d_rec)[2].Pt(),totalW);
      hMu3_pt->Fill((*vMuon_4d_rec)[0].Pt(),totalW);
    }
    if( (*vMuon_4d_rec)[1].Pt() >=(*vMuon_4d_rec)[2].Pt() )
    if( (*vMuon_4d_rec)[0].Pt() >=(*vMuon_4d_rec)[2].Pt() )
    if( (*vMuon_4d_rec)[1].Pt() >=(*vMuon_4d_rec)[0].Pt() )
    if( (*vMuon_4d_rec)[1].Pt() > Cuts.firstMu && (*vMuon_4d_rec)[0].Pt() > Cuts.secndMu && (*vMuon_4d_rec)[2].Pt() > Cuts.thirdMu)
    {
      MuonPtCut = true;
      hTriMuOrder->Fill(6,totalW);
      hMu1_pt->Fill((*vMuon_4d_rec)[1].Pt(),totalW);
      hMu2_pt->Fill((*vMuon_4d_rec)[0].Pt(),totalW);
      hMu3_pt->Fill((*vMuon_4d_rec)[2].Pt(),totalW);
    }


    int diMuonCombi(-1);
    if( Nmuon >= 3 && MuonPtCut){
      //cout<<"WG* Sample!"<<endl;
      double mMini_mumu(1000000000.);
      if( (*vMuon_Flv_rec)[0] * (*vMuon_Flv_rec)[1] < 0)
      {
        TLorentzVector mumu4d = (*vMuon_4d_rec)[0];
        mumu4d += (*vMuon_4d_rec)[1];
        mMini_mumu = mumu4d.M();
	diMuonCombi=0;
      }
      if( (*vMuon_Flv_rec)[0] * (*vMuon_Flv_rec)[2] < 0)
      {
        TLorentzVector mumu4d = (*vMuon_4d_rec)[0];
        mumu4d += (*vMuon_4d_rec)[2];
        if( mumu4d.M() < mMini_mumu ){
	  mMini_mumu = mumu4d.M();
	  diMuonCombi=1;
	}
      }
      if( (*vMuon_Flv_rec)[1] * (*vMuon_Flv_rec)[2] < 0)
      {
        TLorentzVector mumu4d = (*vMuon_4d_rec)[1];
        mumu4d += (*vMuon_4d_rec)[2];
        if( mumu4d.M() < mMini_mumu ){
	  mMini_mumu = mumu4d.M();
	  diMuonCombi=2;
	}
      }
      if( diMuonCombi== -1 ) continue;

      if( abs(mMini_mumu - JpsiMASS) < 0.1 ) continue;
      // id check
      switch( diMuonCombi)
      {
	case 0:
	  {
	    if( ((*vMuon_isWgsLepton_rec)[2] != 1) ) continue;
            if( ((*vMuon_isWgsLepton_rec)[0] != 1) ) continue;
            if( ((*vMuon_isWgsLepton_rec)[1] != 1) ) continue;
	    break;
	  }
	case 1:
	  {
	    if( ((*vMuon_isWgsLepton_rec)[1] != 1) ) continue;
            if( ((*vMuon_isWgsLepton_rec)[0] != 1) ) continue;
            if( ((*vMuon_isWgsLepton_rec)[2] != 1) ) continue;
	    break;
	  }
	case 2:
	  {
	    if( ((*vMuon_isWgsLepton_rec)[0] != 1) ) continue;
            if( ((*vMuon_isWgsLepton_rec)[1] != 1) ) continue;
            if( ((*vMuon_isWgsLepton_rec)[2] != 1) ) continue;
	    break;
	  }
	default:
	  continue;
      }
      //cout<<"mMini_mumu: "<<mMini_mumu<<endl;
      //if(mMini_mumu < 15)
      //{
	hInvDimu_Recon->Fill(mMini_mumu, totalW);
	if(!theSample.Contains("Data"))hInvDimu_Gen->Fill(Gen_ZGstar_mass, totalW);
      //}
    }

  }

  // Save the histograms
  //----------------------------------------------------------------------------
  output->cd();
  output->Write("", TObject::kOverwrite);
  output->Close();
  //Fout.close();
}
예제 #11
0
void Aprendizagem_Reforco::loadReport( int playerNum )
{
	char fileNumber[2]; // player number
	char dir[] = "report/ReportXX.csv"; // better not change this

	switch( playerNum ){
	case 0:
		fileNumber[0] = '0';
		fileNumber[1] = '0';
		break;
	case 1:
		fileNumber[0] = '0';
		fileNumber[1] = '1';
		break;
	case 2:
		fileNumber[0] = '0';
		fileNumber[1] = '2';
		break;
	case 3:
		fileNumber[0] = '0';
		fileNumber[1] = '3';
		break;
	case 4:
		fileNumber[0] = '0';
		fileNumber[1] = '4';
		break;
	case 5:
		fileNumber[0] = '0';
		fileNumber[1] = '5';
		break;
	case 6:
		fileNumber[0] = '0';
		fileNumber[1] = '6';
		break;
	case 7:
		fileNumber[0] = '0';
		fileNumber[1] = '7';
		break;
	case 8:
		fileNumber[0] = '0';
		fileNumber[1] = '8';
		break;
	case 9:
		fileNumber[0] = '0';
		fileNumber[1] = '9';
		break;
	case 10:
		fileNumber[0] = '1';
		fileNumber[1] = '0';
		break;
	case 11:
		fileNumber[0] = '1';
		fileNumber[1] = '1';
		break;
	case 12:
		fileNumber[0] = '1';
		fileNumber[1] = '2';
		break;
	}

	dir[13] = fileNumber[0];
	dir[14] = fileNumber[1];

	ifstream Fin( dir, ios::in );
	if (!Fin) // "Tried to read but failed, recreating/overwriting file"
	{
		ofstream Fout( dir, ios::out );
		if (!Fout) // Couldn't open for writing! path doesn't exist ? (check dir)
		{
			cerr << "ERROR while creating Report for player " << playerNum << "\n";
		}
		else // File successfully opened for writing
		{
			Fout << "Num_Jogo ";
			Fout << "Num_Acoes ";
			for( int i = 0; i<num_acoes; i++ )
			{
				Fout << "A" << i+1 << " ";
			}
			Fout << "Gols_Feitos ";
			Fout << "Gols_Sofridos ";
			Fout << "Epsilon ";
			Fout << "Exp_Q(%) ";
			Fout << "Exp_H(%) ";
			Fout << "\n";
		}
		Fout.close();
	}
	Fin.close();
}
예제 #12
0
void Aprendizagem_Reforco::saveInfo( int playerNum )
{
	char fileNumber[2]; // player number
	char dir[] = "info/InfoXX.csv"; // better not change this

	switch( playerNum ){
	case 0:
		fileNumber[0] = '0';
		fileNumber[1] = '0';
		break;
	case 1:
		fileNumber[0] = '0';
		fileNumber[1] = '1';
		break;
	case 2:
		fileNumber[0] = '0';
		fileNumber[1] = '2';
		break;
	case 3:
		fileNumber[0] = '0';
		fileNumber[1] = '3';
		break;
	case 4:
		fileNumber[0] = '0';
		fileNumber[1] = '4';
		break;
	case 5:
		fileNumber[0] = '0';
		fileNumber[1] = '5';
		break;
	case 6:
		fileNumber[0] = '0';
		fileNumber[1] = '6';
		break;
	case 7:
		fileNumber[0] = '0';
		fileNumber[1] = '7';
		break;
	case 8:
		fileNumber[0] = '0';
		fileNumber[1] = '8';
		break;
	case 9:
		fileNumber[0] = '0';
		fileNumber[1] = '9';
		break;
	case 10:
		fileNumber[0] = '1';
		fileNumber[1] = '0';
		break;
	case 11:
		fileNumber[0] = '1';
		fileNumber[1] = '1';
		break;
	case 12:
		fileNumber[0] = '1';
		fileNumber[1] = '2';
		break;
	}

	dir[9] = fileNumber[0];
	dir[10] = fileNumber[1];

	ofstream Fout( dir, ios::out );

	if( Fout ) // opened for writing (appending to file)
	{
		Fout << Num_Jogos << "\n" << Num_Itera << "\n";
		cerr << "Successfully saved Info for player " << playerNum << "\n";
	}

	Fout.close();
}
예제 #13
0
void Aprendizagem_Reforco::loadInfo( int playerNum )
{
	char fileNumber[2]; // player number
	char dir[] = "info/InfoXX.csv"; // better not change this

	switch( playerNum ){
	case 0:
		fileNumber[0] = '0';
		fileNumber[1] = '0';
		break;
	case 1:
		fileNumber[0] = '0';
		fileNumber[1] = '1';
		break;
	case 2:
		fileNumber[0] = '0';
		fileNumber[1] = '2';
		break;
	case 3:
		fileNumber[0] = '0';
		fileNumber[1] = '3';
		break;
	case 4:
		fileNumber[0] = '0';
		fileNumber[1] = '4';
		break;
	case 5:
		fileNumber[0] = '0';
		fileNumber[1] = '5';
		break;
	case 6:
		fileNumber[0] = '0';
		fileNumber[1] = '6';
		break;
	case 7:
		fileNumber[0] = '0';
		fileNumber[1] = '7';
		break;
	case 8:
		fileNumber[0] = '0';
		fileNumber[1] = '8';
		break;
	case 9:
		fileNumber[0] = '0';
		fileNumber[1] = '9';
		break;
	case 10:
		fileNumber[0] = '1';
		fileNumber[1] = '0';
		break;
	case 11:
		fileNumber[0] = '1';
		fileNumber[1] = '1';
		break;
	case 12:
		fileNumber[0] = '1';
		fileNumber[1] = '2';
		break;
	}

	dir[9] = fileNumber[0];
	dir[10] = fileNumber[1];

	ifstream Fin( dir, ios::in );
	if (!Fin) // "Tried to read but failed, recreating/overwriting file"
	{
		ofstream Fout( dir, ios::out );
		if (!Fout) // Couldn't open for writing! path doesn't exist ? (check dir)
		{
			cerr << "ERROR while creating Info for player " << playerNum << "\n";
		}
		else // File successfully opened for writing
		{
			Fout << 0 << "\n" << 0 << "\n";
			Num_Jogos = 0;
			Num_Itera = 0;
		}
		Fout.close();
	}
	else
	{
		Fin >> Num_Jogos;
		Fin >> Num_Itera;
	}
	Fin.close();
}
예제 #14
0
void Aprendizagem_Reforco::saveMatrixH( int playerNum )
{
	char fileNumber[2]; // player number
	char dir[] = "matrizes/MatrizHXX.csv"; // better not change this

	switch( playerNum ){
	case 0:
		fileNumber[0] = '0';
		fileNumber[1] = '0';
		break;
	case 1:
		fileNumber[0] = '0';
		fileNumber[1] = '1';
		break;
	case 2:
		fileNumber[0] = '0';
		fileNumber[1] = '2';
		break;
	case 3:
		fileNumber[0] = '0';
		fileNumber[1] = '3';
		break;
	case 4:
		fileNumber[0] = '0';
		fileNumber[1] = '4';
		break;
	case 5:
		fileNumber[0] = '0';
		fileNumber[1] = '5';
		break;
	case 6:
		fileNumber[0] = '0';
		fileNumber[1] = '6';
		break;
	case 7:
		fileNumber[0] = '0';
		fileNumber[1] = '7';
		break;
	case 8:
		fileNumber[0] = '0';
		fileNumber[1] = '8';
		break;
	case 9:
		fileNumber[0] = '0';
		fileNumber[1] = '9';
		break;
	case 10:
		fileNumber[0] = '1';
		fileNumber[1] = '0';
		break;
	case 11:
		fileNumber[0] = '1';
		fileNumber[1] = '1';
		break;
	case 12:
		fileNumber[0] = '1';
		fileNumber[1] = '2';
		break;
	}

	dir[16] = fileNumber[0];
	dir[17] = fileNumber[1];

	ofstream Fout( dir, ios::out );

	if (!Fout) // Couldn't open for writing! path doesn't exist ? (check dir)
	{
		cerr << "ERROR while saving MatrizH for player " << playerNum << "\n";
	}
	else // "Successful in opening the file, saving values of array MatrizH"
	{
		unsigned long long numElementos = 0;
		unsigned long long difZero = 0;

		for( int i=0; i<num_linesQ; i++ )
		{
			for( int j=0; j<num_acoes; j++ )
			{
				Fout << MatrizH[i][j] << " ";
				numElementos++;
				if( MatrizH[i][j] != 0 )
					difZero++;
			}
			Fout << "\n";
		}
		cerr << "Successfully saved Matrix for player " << playerNum << "\n";
		porcentagemNaoNulosNaMatrizH = (difZero/((double)numElementos*1.0))*100.0;
		cerr << "Matrix info: " << "(" << difZero << "/" << numElementos << ") = "
				<< porcentagemNaoNulosNaMatrizH << "% explored for player " << playerNum << "\n";
	}
	Fout.close();
}
예제 #15
0
void Aprendizagem_Reforco::loadMatrixH( int playerNum )
{
	char fileNumber[2]; // player number
	char dir[] = "matrizes/MatrizHXX.csv"; // better not change this

	switch( playerNum ){
	case 0:
		fileNumber[0] = '0';
		fileNumber[1] = '0';
		break;
	case 1:
		fileNumber[0] = '0';
		fileNumber[1] = '1';
		break;
	case 2:
		fileNumber[0] = '0';
		fileNumber[1] = '2';
		break;
	case 3:
		fileNumber[0] = '0';
		fileNumber[1] = '3';
		break;
	case 4:
		fileNumber[0] = '0';
		fileNumber[1] = '4';
		break;
	case 5:
		fileNumber[0] = '0';
		fileNumber[1] = '5';
		break;
	case 6:
		fileNumber[0] = '0';
		fileNumber[1] = '6';
		break;
	case 7:
		fileNumber[0] = '0';
		fileNumber[1] = '7';
		break;
	case 8:
		fileNumber[0] = '0';
		fileNumber[1] = '8';
		break;
	case 9:
		fileNumber[0] = '0';
		fileNumber[1] = '9';
		break;
	case 10:
		fileNumber[0] = '1';
		fileNumber[1] = '0';
		break;
	case 11:
		fileNumber[0] = '1';
		fileNumber[1] = '1';
		break;
	case 12:
		fileNumber[0] = '1';
		fileNumber[1] = '2';
		break;
	}

	dir[16] = fileNumber[0];
	dir[17] = fileNumber[1];

	ifstream Fin( dir, ios::in );
	if (!Fin) // "Tried to read but failed, recreating/overwriting file"
	{
		ofstream Fout( dir, ios::out );
		if (!Fout) // Couldn't open for writing! path doesn't exist ? (check dir)
		{
			cerr << "ERROR while creating MatrizH for player " << playerNum << "\n";
			for( int i=0; i<num_linesQ; i++ )
			{
				for( int j=0; j<num_acoes; j++ )
					MatrizH[i][j] = 0.0; // passing values to array MatrizH
			}
		}
		else // File successfully opened for writing
		{
			for( int i=0; i<num_linesQ; i++ )
			{
				for( int j=0; j<num_acoes; j++ )
				{
					Fout << "0 ";
					MatrizH[i][j] = 0.0; // passing values to array MatrizH
				}
				Fout << "\n";
			}
			cerr << "Successfully created Matrix for player " << playerNum << "\n";
		}
		Fout.close();
	}
	else // "Successful in reading, pass values to array MatrizH"
	{
		for( int i=0; i<num_linesQ; i++ )
		{
			for( int j=0; j<num_acoes; j++ )
			{
				Fin >> MatrizH[i][j];
			}
		}
		cerr << "Successfully read Matrix for player " << playerNum << "\n";
	}
	Fin.close();
}
예제 #16
0
void Aprendizagem_Reforco::saveReport( int playerNum )
{
	char fileNumber[2]; // player number
	char dir[] = "report/ReportXX.csv"; // better not change this

	switch( playerNum ){
	case 0:
		fileNumber[0] = '0';
		fileNumber[1] = '0';
		break;
	case 1:
		fileNumber[0] = '0';
		fileNumber[1] = '1';
		break;
	case 2:
		fileNumber[0] = '0';
		fileNumber[1] = '2';
		break;
	case 3:
		fileNumber[0] = '0';
		fileNumber[1] = '3';
		break;
	case 4:
		fileNumber[0] = '0';
		fileNumber[1] = '4';
		break;
	case 5:
		fileNumber[0] = '0';
		fileNumber[1] = '5';
		break;
	case 6:
		fileNumber[0] = '0';
		fileNumber[1] = '6';
		break;
	case 7:
		fileNumber[0] = '0';
		fileNumber[1] = '7';
		break;
	case 8:
		fileNumber[0] = '0';
		fileNumber[1] = '8';
		break;
	case 9:
		fileNumber[0] = '0';
		fileNumber[1] = '9';
		break;
	case 10:
		fileNumber[0] = '1';
		fileNumber[1] = '0';
		break;
	case 11:
		fileNumber[0] = '1';
		fileNumber[1] = '1';
		break;
	case 12:
		fileNumber[0] = '1';
		fileNumber[1] = '2';
		break;
	}

	dir[13] = fileNumber[0];
	dir[14] = fileNumber[1];

	ofstream Fout( dir, ios::app );

	if( Fout ) // opened for writing (appending to file)
	{
		Fout << Num_Jogos << " ";
		for( int i = 0; i<num_acoes+6; i++ )
		{
			Fout << VetorRelatorio[i] << " ";
		}
		Fout << "\n";
		cerr << "Successfully saved Report for player " << playerNum << "\n";
	}

	Fout.close();
}