示例#1
0
void plotSteps()
{

  //checkInputs(); return;

  TFile fin("/mnt/sdc/andriusj/DY13TeV/DYanalysis-20160817/ElectronNtupler/test/Analysis_Codes/AccEff/dyee_preFSR_forAccEff_v1steps.root");
  TH1D *h1effPass_new= loadHisto(fin,"h1_eff_sumPass","h1effPass_new",1,h1dummy);
  TH1D *h1effPass_noPU= loadHisto(fin,"h1_eff_sumPass_noPU","h1effPass_noPU",1,h1dummy);
  TH1D *h1effPass_noTrigObjMatching= loadHisto(fin,"h1_eff_sumPass_noTrigObjMatching","h1effPass_noTrigObjMatching",1,h1dummy);
  TH1D *h1effPass_matchDR3= loadHisto(fin,"h1_eff_sumPass_matchDR3","h1effPass_matchDR3",1,h1dummy);
  TH1D *h1effPass_noTrig= loadHisto(fin,"h1_eff_sumPass_noTrig","h1effPass_noTrig",1,h1dummy);
  TH1D *h1effPass_noTrigNoPU= loadHisto(fin,"h1_eff_sumPass_noTrigNoPU","h1effPass_noTrigNoPU",1,h1dummy);
  //TH1D *h1effTot_new= loadHisto(fin, "h1_eff_sumTot", "h1effTot_new",1,h1dummy);
  fin.Close();
  if (!h1effPass_new  || !h1effPass_noPU || !h1effPass_noTrigObjMatching ||
      !h1effPass_matchDR3 || !h1effPass_noTrig || !h1effPass_noTrigNoPU) {
    std::cout << "null ptr\n";
    return;
  }

  std::vector<TH1D*> h1InfoV;
  std::vector<TString> infoLabelV;

  histoStyle(h1effPass_noPU,kRed,5,1);
  histoStyle(h1effPass_noTrig,kBlue,7,2);
  histoStyle(h1effPass_matchDR3,kGreen+1,5,1);
  histoStyle(h1effPass_noTrigObjMatching,kOrange,20,2);

  std::cout << "\nwPU effect on new effPass distribution\n";
  plotHisto(h1effPass_new,"cPUnew",1,0,"LPE1","new wPU");
  plotHistoSame(h1effPass_noPU,"cPUnew","LPE1","new noPU");
  printRatio(h1effPass_new,h1effPass_noPU);
  addRatio(h1effPass_noPU,h1effPass_new,"no PU rew.",h1InfoV,infoLabelV);

  std::cout << "\nwPU effect on old effPass distribution\n";
  plotHisto(h1effPass_noTrig,"cPUold",1,0,"LPE1","old wPU");
  plotHistoSame(h1effPass_noTrigNoPU,"cPUold","LPE1","old noPU");
  printRatio(h1effPass_noTrig,h1effPass_noTrigNoPU);

  std::cout << "\ntriggering\n";
  plotHisto(h1effPass_new,"cTrig",1,0,"LPE1","new wPU");
  plotHistoSame(h1effPass_noTrig,"cTrig","LPE1","no event trigger");
  printRatio(h1effPass_new,h1effPass_noTrig);
  addRatio(h1effPass_noTrig,h1effPass_new,"no trigger",h1InfoV,infoLabelV);

  std::cout << "\ntrigger object matching\n";
  plotHisto(h1effPass_new,"cTrigObjMatch",1,0,"LPE1","new wPU");
  plotHistoSame(h1effPass_noTrigObjMatching,"cTrigObjMatch","LPE1","new, noTrigObjMatch");
  printRatio(h1effPass_new,h1effPass_noTrigObjMatching);
  addRatio(h1effPass_noTrigObjMatching,h1effPass_new,"no trig.obj.match.",h1InfoV,infoLabelV);

  std::cout << "\nDR effect on new effPass distribution\n";
  plotHisto(h1effPass_new,"cDR",1,0,"LPE1","new wPU, match DR1");
  plotHistoSame(h1effPass_matchDR3,"cDR","LPE1","new wPU, match DR3");
  printRatio(h1effPass_new,h1effPass_matchDR3);
  addRatio(h1effPass_matchDR3,h1effPass_new,"#DeltaR<0.3",h1InfoV,infoLabelV);

  //printLatex("effPassSteps.tex",h1InfoV,infoLabelV,1);
  plotRatios(h1InfoV,infoLabelV);
}
示例#2
0
void MLScale::setDefaultScale()
{
	clear();
	setName("12-equal");
	setDescription("The chromatic equal-tempered scale.");
	// make 12-ET scale	
	for(int i=1; i<=12; ++i)
	{
		addRatio(100.0 * i);
	}
}
示例#3
0
// Return true if we successfully read a tuning file, false otherwise
boolean Tuning::read() {

	scalaFile = SD.open(_filename);

	char character;

	boolean inComment = false;

	int numEntries = 0;
	ratios[0] = 1.0;
	numRatios = 1;

	int DESCRIPTION_STATE = 1;
	int ENTRIES_STATE = 2;
	int RATIO_STATE = 3;

	int state = DESCRIPTION_STATE;

	String currentLine = "";

	String description;

    while (scalaFile.available()) {
        character = scalaFile.read();

        // If we're in a comment just keep reading until we hit the next line
        if(inComment) {
        	if(character == '\n') {
        		inComment = false;
        	}
        	continue;
        }
        if(character == '!') {
        	// Line is a comment, ignore until end
        	inComment = true;
        	if(state == RATIO_STATE && currentLine.length() > 1) {
        		// If a comment has started on a ratio line, we can process the ratio
        		if(addRatio(&currentLine)) {
        			break;
        		}
        		currentLine = "";
        	}
        	continue;
        } else {
        	inComment = false;
        }

        if(state == DESCRIPTION_STATE) {
        	if(character == '\n') {
        		state = ENTRIES_STATE;
        		if(currentLine.length() == 0) {
        			description = "No Info";
        		} else {
        			description = currentLine;
        		}
				#ifdef DEBUG_TUNING
        		Serial.println("End description");
        		Serial.println(description);
				#endif

        		currentLine = "";
        	} else {
        		currentLine += character;
        	}
        } else if(state == ENTRIES_STATE) {
        	if(character == '\n') {
        		state = RATIO_STATE;
        		numEntries = currentLine.toInt();
        		if(numEntries == 0) {
        			return false;
        		}
				#ifdef DEBUG_TUNING
        		Serial.print("End num entries: ");
        		Serial.println(numEntries);
				#endif

        		currentLine = "";
        	} else {
        		currentLine += character;
        	}
        } else if(state == RATIO_STATE) {
        	if(character == '\n') {
				#ifdef DEBUG_TUNING
        		Serial.print("Got ratio");
        		Serial.println(currentLine);
				#endif

        		if(addRatio(&currentLine)) {
        			break;
        		}
        		currentLine = "";
        	} else {
        		currentLine += character;
        	}
        }
    }

    scalaFile.close();

	#ifdef DEBUG_TUNING
    if(numEntries != numRatios) {
    	Serial.print("Entries and Ratio Count not equal. ");
    	Serial.print(numEntries);
    	Serial.print(" vs ");
    	Serial.println(numRatios);
    }
	#endif

    if(numRatios > 1) {
    	return true;
    }

    return false;
}
示例#4
0
void Job::evaluate(Brain * brain)
{
    //
    addRatio(brain->getRatio());
    addBalance(brain->getBalance());
    addError(brain->getError());
    QString fileName = saveDirectory + "/" +
            QString::number(brain->getBalance(),'f',2) + " | " +
            QString::number(brain->getRatio(),'f',4) + " | " +
            QString::number(brain->getError(),'f',2) +".brain";
    //
    if(evaluationMode == BALANCE)
    {
        mutexAverageBalance.lock();
        float averageBalanceTmp = averageBalance;
        mutexAverageBalance.unlock();
        if(brain->getBalance() > averageBalanceTmp)
        {
            copyToBestBrain(brain);
        }
        if(brain->getBalance() > bestBalanceEver)
        {
            copyToBestBrainEver(brain);
            bestBalanceEver = brain->getBalance();
            saveBestBrain(fileName);
        }
    }
    else if(evaluationMode == RATIO)
    {
        mutexAverageRatio.lock();
        float averageRatioTmp = averageRatio;
        mutexAverageRatio.unlock();
        if(brain->getRatio() > averageRatioTmp)
        {
            copyToBestBrain(brain);
        }
        /*if(brain->getRatio() > bestRatioEver)
        {
            copyToBestBrainEver(brain);
            bestRatioEver = brain->getRatio();
            saveBestBrain(fileName);
        }*/
    }
    else if(evaluationMode == ERROR)
    {
        mutexAverageError.lock();
        float averageErrorTmp = averageError;
        mutexAverageError.unlock();
        if(brain->getError() < averageErrorTmp)
        {
            copyToBestBrain(brain);
        }
        if(brain->getError() < bestErrorEver)
        {
            copyToBestBrainEver(brain);
            bestErrorEver = brain->getError();
            saveBestBrain(fileName);
        }
    }
    //
    copyFromBestBrain(brain);
    brain->mutate(mutationFrequency, mutationIntensity);
}
示例#5
0
void MLScale::clear()
{
	mRatioList.clear();
	addRatio(0.0);
}