예제 #1
0
파일: assess.c 프로젝트: FishyByte/SushiRNG
int
main(int argc, char *argv[])
{
	int		i;
	int		option;			/* TEMPLATE LENGTH/STREAM LENGTH/GENERATOR*/
	char	*streamFile;	/* STREAM FILENAME     */
	

	if ( argc != 2 ) {
		printf("Usage: %s <stream length>\n", argv[0]);
		printf("   <stream length> is the length of the individual bit stream(s) to be processed\n");
		return 0;
	}

	tp.n = atoi(argv[1]);
	tp.blockFrequencyBlockLength = 128;
	tp.nonOverlappingTemplateBlockLength = 9;
	tp.overlappingTemplateBlockLength = 9;
	tp.approximateEntropyBlockLength = 10;
	tp.serialBlockLength = 16;
	tp.linearComplexitySequenceLength = 500;
	tp.numOfBitStreams = 1;
	option = generatorOptions(&streamFile);
	chooseTests();
	fixParameters();
	openOutputStreams(option);
	invokeTestSuite(option, streamFile);
	fclose(freqfp);
	for( i=1; i<=NUMOFTESTS; i++ ) {
		if ( stats[i] != NULL )
			fclose(stats[i]);
		if ( results[i] != NULL )
			fclose(results[i]);
	}
	if ( (testVector[0] == 1) || (testVector[TEST_CUSUM] == 1) ) 
		partitionResultFile(2, tp.numOfBitStreams, option, TEST_CUSUM);
	if ( (testVector[0] == 1) || (testVector[TEST_NONPERIODIC] == 1) ) 
		partitionResultFile(MAXNUMOFTEMPLATES, tp.numOfBitStreams, option, TEST_NONPERIODIC);
	if ( (testVector[0] == 1) || (testVector[TEST_RND_EXCURSION] == 1) )
		partitionResultFile(8, tp.numOfBitStreams, option, TEST_RND_EXCURSION);
	if ( (testVector[0] == 1) || (testVector[TEST_RND_EXCURSION_VAR] == 1) )
		partitionResultFile(18, tp.numOfBitStreams, option, TEST_RND_EXCURSION_VAR);
	if ( (testVector[0] == 1) || (testVector[TEST_SERIAL] == 1) )
		partitionResultFile(2, tp.numOfBitStreams, option, TEST_SERIAL);
	fprintf(summary, "------------------------------------------------------------------------------\n");
	fprintf(summary, "RESULTS FOR THE UNIFORMITY OF P-VALUES AND THE PROPORTION OF PASSING SEQUENCES\n");
	fprintf(summary, "------------------------------------------------------------------------------\n");
	fprintf(summary, "   generator is <%s>\n", streamFile);
	fprintf(summary, "------------------------------------------------------------------------------\n");
	fprintf(summary, " C1  C2  C3  C4  C5  C6  C7  C8  C9 C10  P-VALUE  PROPORTION  STATISTICAL TEST\n");
	fprintf(summary, "------------------------------------------------------------------------------\n");
	postProcessResults(option);
	fclose(summary);

	return 1;
}
예제 #2
0
///
/// Test PDF implementation.
/// Performs a fit to the minimum.
///
bool PDF_Abs::test()
{
	bool quiet = false;
	if(quiet) RooMsgService::instance().setGlobalKillBelow(ERROR);
	fixParameters(observables);
	floatParameters(parameters);
	setLimit(parameters, "free");
	RooFormulaVar ll("ll", "ll", "-2*log(@0)", RooArgSet(*pdf));
	RooMinuit m(ll);
	if(quiet) m.setPrintLevel(-2);
	m.setNoWarn();
	m.setLogFile("/dev/zero");
	m.setErrorLevel(1.0);
	m.setStrategy(2);
	// m.setProfile(1);
	m.migrad();
	RooFitResult *f = m.save();
	bool status = !(f->edm()<1 && f->status()==0);
	if(!quiet) f->Print("v");
	delete f;
	if(quiet) RooMsgService::instance().setGlobalKillBelow(INFO);
	if(!quiet) cout << "pdf->getVal() = " << pdf->getVal() << endl;
	return status;
}
예제 #3
0
///
/// scan engine
///
void GammaComboEngine::scan()
{
    for ( int i=0; i<arg->combid.size(); i++ )
    {
        int combinerId = arg->combid[i];
        Combiner *c = cmb[combinerId];

        // work with a clone - this way we can easily make plots with the
        // same combination in twice (once with asimov, for example)
        c = c->Clone(c->getName(), c->getTitle());

        // fix parameters according to the command line - only possible before combining
        fixParameters(c, i);

        // configure names to run an Asimov toy - only possible before combining
        if ( arg->isAsimovCombiner(i) ) configureAsimovCombinerNames(c, i);

        // configure scans for observables - this part is only possible before combining
        if ( isScanVarObservable(c, arg->var[0]) ) {
            tightenChi2Constraint(c, arg->var[0]);
        }
        if ( arg->var.size()==2 && isScanVarObservable(c, arg->var[1]) ) {
            tightenChi2Constraint(c, arg->var[1]);
        }

        // combine
        c->combine();
        if ( !c->isCombined() ) continue; // error during combining

        // adjust ranges according to the command line - only possible before combining
        adjustRanges(c, i);

        // make graphviz dot files
        printCombinerStructure(c);

        // set an asimov toy - only possible after combining
        if ( arg->isAsimovCombiner(i) ) loadAsimovPoint(c, i);

        // configure scans for observables - this part is only possible after combining
        // add the observable(s) to the list of parameters
        if ( isScanVarObservable(c, arg->var[0]) ) {
            c->getWorkspace()->extendSet(c->getParsName(), arg->var[0]);
        }
        if ( arg->var.size()==2 && isScanVarObservable(c, arg->var[1]) ) {
            c->getWorkspace()->extendSet(c->getParsName(), arg->var[1]);
        }

        // printout
        c->print();
        if ( arg->debug ) c->getWorkspace()->Print("v");

        /////////////////////////////////////////////////////
        //
        // PROB
        //
        /////////////////////////////////////////////////////

        if ( !arg->isAction("plugin") && !arg->isAction("pluginbatch") )
        {
            MethodProbScan *scannerProb = new MethodProbScan(c);
            // pvalue corrector
            if ( arg->coverageCorrectionID>0 ) {
                PValueCorrection *pvalueCorrector = new PValueCorrection(arg->coverageCorrectionID, arg->verbose);
                pvalueCorrector->readFiles(m_fnamebuilder->getFileBaseName(c),arg->coverageCorrectionPoint,false); // false means for prob
                pvalueCorrector->write("root/pvalueCorrection_prob.root");
                scannerProb->setPValueCorrector(pvalueCorrector);
            }

            // 1D SCANS
            if ( arg->var.size()==1 )
            {
                if ( arg->isAction("plot") ) {
                    scannerProb->loadScanner(m_fnamebuilder->getFileNameScanner(scannerProb));
                }
                else {
                    make1dProbScan(scannerProb, i);
                }
                make1dProbPlot(scannerProb, i);
            }
            // 2D SCANS
            else if ( arg->var.size()==2 )
            {
                if ( arg->isAction("plot") ) {
                    scannerProb->loadScanner(m_fnamebuilder->getFileNameScanner(scannerProb));
                }
                else {
                    make2dProbScan(scannerProb, i);
                }
                make2dProbPlot(scannerProb, i);
            }
        }

        /////////////////////////////////////////////////////
        //
        // PLUGIN
        //
        /////////////////////////////////////////////////////

        if ( arg->isAction("plugin") || arg->isAction("pluginbatch") )
        {
            // 1D SCANS
            if ( arg->var.size()==1 )
            {
                if ( arg->isAction("pluginbatch") ) {
                    MethodProbScan *scannerProb = new MethodProbScan(c);
                    make1dProbScan(scannerProb, i);
                    MethodPluginScan *scannerPlugin = new MethodPluginScan(scannerProb);
                    make1dPluginScan(scannerPlugin, i);
                }
                //if ( arg->isAction("pluginhybridbatch") ){
                //// Hybrid Plugin: compute a second profile likelihood to define the parameter evolution
                //cout << "HYBRID PLUGIN: preparing profile likelihood to be used for parameter evolution:" << endl;
                //ParameterCache *pCache = new ParameterCache(arg, m_fnamebuilder->getFileBaseName(cmb[arg->pevid[0]]));
                //pCache->loadPoints();
                //MethodProbScan *scanner3 = new MethodProbScan(cmb[arg->pevid[0]]);
                //scanner3->initScan();
                //scanStrategy1d(scanner3,pCache);
                //scanner3->confirmSolutions();
                //scanner3->printLocalMinima();
                //scanner2->setParevolPLH(scanner3);
                //}
                else if ( arg->isAction("plugin") ) {
                    // Create the Prob scanner: load from disc if it exists, else redo the scan.
                    // We don't need the prob scanner for the plugin only plot, if we either just
                    // want to replot it.
                    MethodProbScan *scannerProb = new MethodProbScan(c);
                    if (    !arg->plotpluginonly
                            || ( arg->plotpluginonly && !arg->isAction("plot") ) ) {
                        if ( FileExists(m_fnamebuilder->getFileNameScanner(scannerProb)) ) {
                            scannerProb->loadScanner(m_fnamebuilder->getFileNameScanner(scannerProb));
                        }
                        else {
                            cout << "\nWARNING : Couldn't load the Prob scanner, will rerun the Prob" << endl;
                            cout <<   "          scan now. You should have run the Prob scan locally" << endl;
                            cout <<   "          before running the Plugin scan." << endl;
                            cout <<   "          missing file: " << m_fnamebuilder->getFileNameScanner(scannerProb) << endl;
                            cout << endl;
                            make1dProbScan(scannerProb, i);
                        }
                    }
                    // create Plugin scanner
                    MethodPluginScan *scannerPlugin = new MethodPluginScan(scannerProb);
                    if ( arg->isAction("plot") ) {
                        scannerPlugin->loadScanner(m_fnamebuilder->getFileNameScanner(scannerPlugin));
                    }
                    else {
                        if ( arg->coverageCorrectionID>0 ) {
                            PValueCorrection *pvalueCorrector= new PValueCorrection(arg->coverageCorrectionID, arg->verbose);
                            pvalueCorrector->readFiles(m_fnamebuilder->getFileBaseName(c),arg->coverageCorrectionPoint,true); // true means for plugin
                            pvalueCorrector->write("root/pvalueCorrection_plugin.root");
                            scannerPlugin->setPValueCorrector(pvalueCorrector);
                        }
                        make1dPluginScan(scannerPlugin, i);
                    }
                    if ( arg->plotpluginonly ) {
                        make1dPluginOnlyPlot(scannerPlugin, i);
                    }
                    else {
                        make1dPluginPlot(scannerPlugin, scannerProb, i);
                    }
                }


            }
            // 2D SCANS
            else if ( arg->var.size()==2 ) {
                if ( arg->isAction("pluginbatch") ) {
                    MethodProbScan *scannerProb = new MethodProbScan(c);
                    make2dProbScan(scannerProb, i);
                    MethodPluginScan *scannerPlugin = new MethodPluginScan(scannerProb);
                    make2dPluginScan(scannerPlugin, i);
                }
                else if ( arg->isAction("plugin") ) {
                    MethodProbScan *scannerProb = new MethodProbScan(c);
                    if ( ! ( arg->isAction("plot") && arg->plotpluginonly ) ) {
                        // we don't need the prob scanner if we just want to replot the plugin only
                        scannerProb->loadScanner(m_fnamebuilder->getFileNameScanner(scannerProb));
                    }
                    MethodPluginScan *scannerPlugin = new MethodPluginScan(scannerProb);
                    if ( arg->isAction("plot") ) {
                        scannerPlugin->loadScanner(m_fnamebuilder->getFileNameScanner(scannerPlugin));
                    }
                    else {
                        make2dPluginScan(scannerPlugin, i);
                    }
                    if ( arg->plotpluginonly ) {
                        make2dPluginOnlyPlot(scannerPlugin, i);
                    }
                    else {
                        make2dPluginPlot(scannerPlugin, scannerProb, i);
                    }
                }
            }
        }

        /////////////////////////////////////////////////////

        if ( i<arg->combid.size()-1 ) {
            cout << "\n-- now starting -c " << arg->combid[i+1] << " ------------------------------------------------------------------\n" << endl;
        }
    }
}
예제 #4
0
///
/// Fix each parameter in the named set "parname" inside workspace "w".
///
void Utils::fixParameters(RooWorkspace* w, TString parname)
{
	if ( w->set(parname) ) fixParameters(w->set(parname));
}