Пример #1
0
void beffAnalysis(const char* input, const char* output) {
  // input
  TFile* inputFile = TFile::Open(input);
  TTree* btagEff = (TTree*)inputFile->Get("btagEff");

  // output
  TFile* outputFile = TFile::Open(output,"RECREATE");

  // histogram with proper binning... cloned later on 
  Double_t binning[23] = {20,25,30,35,40,45,50,55,60,65,70,75,80,85,90,95,100,120,140,160,180,200,1000};
  TH1F* ptSpectrum = new TH1F("PtSpectrum","PtSpectrum",22,binning);
  ptSpectrum->Sumw2();

  // produce the ratio plot for the 12 combinations of (CSVL,CSVM,CSVT),(Barrel,Endcap),(b,c,l)
  TClonesArray algorithms("TCut",3);
  new(algorithms[0]) TCut("CSVL","csv>0.244");
  new(algorithms[1]) TCut("CSVM","csv>0.679");
  new(algorithms[2]) TCut("CSVT","csv>0.898");

  TClonesArray etaRegions("TCut",2);
  new(etaRegions[0]) TCut("Barrel","abs(eta)<=1.2");
  new(etaRegions[1]) TCut("Endcaps","abs(eta)>1.2");

  TClonesArray flavor("TCut",3);
  new(flavor[0]) TCut("l","abs(flavor)!=4 && abs(flavor)!=5");
  new(flavor[1]) TCut("c","abs(flavor)==4");
  new(flavor[2]) TCut("b","abs(flavor)==5");

  for(int i=0; i< algorithms.GetEntries() ; ++i) {
    outputFile->mkdir(((TCut*)algorithms.At(i))->GetName());
    outputFile->cd(((TCut*)algorithms.At(i))->GetName());
    for(int j=0; j< etaRegions.GetEntries() ; ++j) {
      for(int k=0; k< flavor.GetEntries() ; ++k) {
        // histogram before tagging
        TH1F* pretag = ptSpectrum->Clone("pretag");
        btagEff->Draw("pt>>pretag",((*(TCut*)etaRegions.At(j))&&(*(TCut*)flavor.At(k)))*"eventWeight");
        // histogram after tagging
        TH1F* posttag = ptSpectrum->Clone("posttag");
        btagEff->Draw("pt>>posttag",((*(TCut*)algorithms.At(i))&&(*(TCut*)etaRegions.At(j))&&(*(TCut*)flavor.At(k)))*"eventWeight");
        // ratio
        TH1F* ratio = posttag->Clone(Form("h_eff_bTagOverGoodJet_pt%s_%s",((TCut*)flavor.At(k))->GetName(),
                                                                          ((TCut*)etaRegions.At(j))->GetName()));
        ratio->Divide(pretag);
        // cleanup
        delete pretag;
        delete posttag;
      }
    }
  }

  // cleanup
  algorithms.Delete();
  etaRegions.Delete();
  flavor.Delete();
  ptSpectrum->SetDirectory(0);
  outputFile->Write();
  outputFile->Close();
  inputFile->Close();
}
Пример #2
0
void RGBMatrixEditor::setAlgorithmIndex(int algoIndex)
{
    qDebug() << "Set algorithm:" << algoIndex;
    QStringList algoList = algorithms();
    if(algoIndex < 0 || algoIndex >= algorithms().count())
        return;

    RGBAlgorithm* algo = RGBAlgorithm::algorithm(m_doc, algoList.at(algoIndex));
    if (algo != NULL)
        algo->setColors(m_matrix->startColor(), m_matrix->endColor());
    m_matrix->setAlgorithm(algo);

    initPreviewData();

    emit algorithmIndexChanged();
    emit algoColorsChanged();
}
Пример #3
0
int RGBMatrixEditor::algorithmIndex() const
{
    if (m_matrix == NULL || m_matrix->algorithm() == NULL)
        return -1;

    QStringList algoList = algorithms();
    return algoList.indexOf(m_matrix->algorithm()->name());
}
Пример #4
0
int loopMenu_Maths() {
	

	char options[11];
	std::string fail;
	
	options[0]='1';
	options[1]='2';
	options[2]='3';
	options[3]='4';
	options[4]='5';
	options[5]='6';
	options[6]='7';
	options[7]='8';
	options[8]='9';
	options[9]='a';
	options[10]='x';
	
	bool Exit=false;
	do{
	
		showMenu_Maths();
		
		std::string choice = loopMenu(options,11);
		
		//std::cout << choice << std::endl;
		
	
		if (choice=="1") {
			if(add()) std::cout << "Function Failed";
		} else if (choice=="2") {
			if(subtract()) std::cout << "Function Failed";	
		} else if (choice=="3") {
			if(multiply()) std::cout << "Function Failed";
		} else if (choice=="4") {
			if(divide()) std::cout << "Function Failed";
		} else if (choice=="5") {
			if(intercept()) std::cout << "Function Failed";
		} else if (choice=="6") {
			if(threevector()) std::cout << "Function Failed";
		} else if (choice=="7") {
			if(rootsOfQuadratic()) std::cout << "Function Failed";
		} else if (choice=="8") {
			if(swapInterface(fail)) std::cout << "Function Failed - " << fail;
		} else if (choice=="9") {
			if(bubbleSortInterface(fail)) std::cout << "Function Failed - " << fail;
		} else if (choice=="a") {
			if(algorithms()) std::cout << "Function Failed - " << fail;
		} else if (choice=="x") {
			Exit=true;
		}	
	}while(false==Exit);	
		
	//delete [] options;*/
	return 0;
}
Пример #5
0
int main(int argc, char** argv) {

  // Initialize the Qt Application
  QGuiApplication app(argc, argv);

  // Register the HullRenderer QML Type
  qmlRegisterType<HullRenderer>("com.nearce.HullRenderer", 1, 0, "HullRenderer");

  // Establish the Qt Quick View
  QQuickView view;

  // Create the algorithm objecsts
  GrahamScan grahamScan;
  JarvisMarch jarvisMarch;

  // Create the input genration objects
  RandomPointInput randomPointInput(50, 1000);
  CircularPointInput circularPointInput(50, 1000);

  // Establish list of avalible alogrithms & inputs for the Hull Solver
  QMap<QString, HullAlgorithm*> algorithms({
    {grahamScan.name(), &grahamScan},
    {jarvisMarch.name(), &jarvisMarch}
  });
  QMap<QString, DataInput*> inputs({
    {randomPointInput.name(), &randomPointInput},
    {circularPointInput.name(), &circularPointInput}
  });

  HullSolver solver(algorithms, inputs);

  // Inject some C++ objects into the QML document structure
  view.engine()->rootContext()->setContextProperty("random_input", &randomPointInput);
  view.engine()->rootContext()->setContextProperty("circular_input", &circularPointInput);
  view.engine()->rootContext()->setContextProperty("hull_solver", &solver);

  // Establish a dynamicly resizing content resize policy & display the QML window
  view.setResizeMode(QQuickView::SizeRootObjectToView);
  view.setSource(QUrl("qrc:///resources/main.qml"));
  view.showMaximized();

  // Create a signal slot connection between the HullRenderer QML object
  // and the hull solver in C++ for convience
  HullRenderer* renderer = view.rootObject()->findChild<HullRenderer*>("renderer");

  QObject::connect(&solver, SIGNAL(solutionFound(const HullTimeline&)),
                   renderer, SLOT(setTimeline(const HullTimeline&)));

  return app.exec();
}
Пример #6
0
 void verify() {
     //1. verify order
     uint last = 0;
     uint freeCount = 0;
     for(int a = 0; a < data.size(); ++a) {
         if(data[a].value) {
             QVERIFY(last < data[a].value);
             last = data[a].value;
         }else{
             ++freeCount;
         }
     }
     KDevelop::EmbeddedTreeAlgorithms<TestItem, TestItemHandler> algorithms(data.data(), data.size(), m_centralFree);
     uint countFree = algorithms.countFreeItems();
     QCOMPARE(freeCount, countFree);
     algorithms.verifyTreeConsistent();
 }