Пример #1
0
///
/// Perform the prob scan.
///
/// \param scanner - the scanner to run the scan with
/// \param cId - the id of this combination on the command line
///
void GammaComboEngine::make1dProbScan(MethodProbScan *scanner, int cId)
{
    // load start parameters
    ParameterCache *pCache = new ParameterCache(arg);
    loadStartParameters(scanner, pCache, cId);

    scanner->initScan();
    scanStrategy1d(scanner, pCache);
    cout << "\nResults:" << endl;
    cout <<   "========\n" << endl;
    scanner->printLocalMinima();
    scanner->calcCLintervals();
    if (!arg->isAction("pluginbatch") && !arg->plotpluginonly) {
        if ( arg->plotpulls ) scanner->plotPulls();
        if ( arg->parevol ) {
            ParameterEvolutionPlotter plotter(scanner);
            plotter.plotParEvolution();
        }
        if ( isScanVarObservable(scanner->getCombiner(), arg->var[0]) ) {
            ParameterEvolutionPlotter plotter(scanner);
            plotter.plotObsScanCheck();
        }
        if (!arg->isAction("plugin")) {
            scanner->saveScanner(m_fnamebuilder->getFileNameScanner(scanner));
            pCache->cacheParameters(scanner,m_fnamebuilder->getFileNamePar(scanner));
        }
    }
}
Пример #2
0
void DispValue::plot() const
{
    int ndim = can_plot();
    if (ndim == 0)
	return;

    if (plotter() == 0)
    {
	string title = make_title(full_name());
	MUTABLE_THIS(DispValue *)->_plotter = new_plotter(title, CONST_CAST(DispValue *,this));
	if (plotter() == 0)
	    return;

	plotter()->addHandler(Died, PlotterDiedHP, (void *)this);
    }
Пример #3
0
void DispValue::set_orientation(DispValueOrientation orientation)
{
    if (_orientation == orientation)
	return;

    _orientation = orientation;
    clear_cached_box();

    if (type() == Simple && plotter() != 0)
	plot();

    // Save orientation for next time
    switch (type())
    {
    case Array:
	app_data.array_orientation = orientation;
	break;

    case List:
    case Struct:
	app_data.struct_orientation = orientation;
	break;

    default:
	break;
    }
}
Пример #4
0
// Destructor helper
void DispValue::clear()
{
    for (int i = 0; i < nchildren(); i++)
	child(i)->unlink();

    static const DispValueArray empty(0);
    _children = empty;

    if (plotter() != 0)
    {
	plotter()->terminate();
	_plotter = 0;
    }

    clear_cached_box();
}
Пример #5
0
int main(int argc, char *argv[])
{
    Chronometer total;
    total.start();
    try {
        Util::check(argv[1] == NULL, "You must specify an output directory.");
        ChronoPlotter plotter(argv[1], new RangeLoop(Population::NUM_SELECTION, 50, 301, 50), "Tiempo (ms)");

        plotter.parameters.putNumber(Population::NUM_CROSSOVER, 0);
        plotter.parameters.putNumber(Dummy::WEIGHS_RANGE, 5);

        JoinEnumLoop linesLoop(ET_SELECTION_ALGORITHM);
        linesLoop.addInnerLoop(new RangeLoop(Population::SIZE, 400, 501, 100));
        linesLoop.addEnumLoop(SA_ROULETTE_WHEEL, NULL);
        linesLoop.addEnumLoop(SA_RANKING, NULL);
        linesLoop.addEnumLoop(SA_TOURNAMENT, new RangeLoop(Population::TOURNAMENT_SIZE, 5, 30, 10));
        linesLoop.addEnumLoop(SA_TRUNCATION, NULL);

        plotter.plotChrono(chronoSelection, "chronoGen_Selection", &linesLoop, 50);

        printf("Exit success.\n");
    } catch (std::string& error) {
        cout << "Error: " << error << endl;
    }

    MemoryManagement::printTotalAllocated();
    MemoryManagement::printTotalPointers();
    MemoryManagement::printListOfPointers();

    total.stop();
    printf("Total time spent: %f \n", total.getSeconds());
    return EXIT_SUCCESS;
}
Пример #6
0
// Update values from VALUE.  Set WAS_CHANGED iff value changed; Set
// WAS_INITIALIZED iff type changed.  If TYPE is given, use TYPE as
// type instead of inferring it.  Note: THIS can no more be referenced
// after calling this function; use the returned value instead.
DispValue *DispValue::update(string& value, 
			     bool& was_changed, bool& was_initialized,
			     DispValueType given_type)
{
    DispValue *source = parse(0, 0, value, 
			      full_name(), name(), given_type);

    if (background(value.length()))
    {
	// Aborted while parsing - use SOURCE instead of original
	DispValue *ret = source->link();
	ret->changed = was_changed = was_initialized = true;

	// Have the new DispValue take over the plotter
	if (ret->plotter() == 0)
	{
	    ret->_plotter = plotter();
	    _plotter = 0;
	}

	unlink();
	return ret;
    }

    DispValue *dv = update(source, was_changed, was_initialized);

    if (was_changed || was_initialized)
	dv->clear_cached_box();

    source->unlink();

    return dv;
}
Пример #7
0
int main(int argc, char *argv[])
{
    Chronometer total;
    total.start();
    try {
        Util::check(argv[1] == NULL, "You must specify an output directory.");
        ChronoPlotter plotter(argv[1], new RangeLoop(Dummy::SIZE, 50, 301, 50), "Tiempo (ms)");

        plotter.parameters.putNumber(PROBABILITY, 0);
        plotter.parameters.putNumber(NUM_TIMES, 0);
        plotter.parameters.putNumber(Dummy::WEIGHS_RANGE, 20);

        plotter.parameters.putNumber(Enumerations::enumTypeToString(ET_IMPLEMENTATION), IT_C);
        plotter.parameters.putNumber(Enumerations::enumTypeToString(ET_FUNCTION), FT_IDENTITY);
        plotter.parameters.putNumber(Dummy::NUM_INPUTS, 2);

        EnumLoop averageLoop(ET_BUFFER, 2, BT_FLOAT, BT_BIT);
        averageLoop.addInnerLoop(new RangeLoop(Dummy::NUM_LAYERS, 1, 2, 1));

        EnumLoop crossLoop(ET_CROSS_LEVEL);
        JoinEnumLoop* crossAlgLoop = new JoinEnumLoop(ET_CROSS_ALG);
        crossLoop.addInnerLoop(crossAlgLoop);
        crossAlgLoop->addEnumLoop(CA_UNIFORM, new RangeLoop(PROBABILITY, 0.2, 0.5, 0.2));
        crossAlgLoop->addEnumLoop(CA_MULTIPOINT, new RangeLoop(NUM_TIMES, 1, 10, 5));
        crossAlgLoop->addEnumLoop(CA_PROPORTIONAL, NULL);

        plotter.plotChronoAveraged(chronoCrossover, "chronoGen_crossover", &crossLoop, &averageLoop, 50);

        EnumLoop mutatAlgLoop(ET_MUTATION_ALG, 2, MA_PER_INDIVIDUAL, MA_PROBABILISTIC);
        mutatAlgLoop.addInnerLoop(new RangeLoop(PROBABILITY, 0.0025, 0.011, 0.0025));

        plotter.plotChronoAveraged(chronoMutations, "chronoGen_mutate", &mutatAlgLoop, &averageLoop, 100);

        EnumLoop resetAlgLoop(ET_RESET_ALG, 2, RA_PER_INDIVIDUAL, RA_PROBABILISTIC);
        resetAlgLoop.addInnerLoop(new RangeLoop(PROBABILITY, 0.0025, 0.011, 0.0025));

        plotter.plotChronoAveraged(chronoReset, "chronoGen_reset", &resetAlgLoop, &averageLoop, 100);

//        // separated files
//
//        EnumLoop filesLoop(ET_BUFFER, 3, BT_FLOAT, BT_BIT, BT_SIGN);
//
//        plotter.plotChronoFiles(chronoCrossover, "Individual_crossover", &crossLoop, &filesLoop, 5);
//        plotter.plotChronoAveraged(chronoMutations, "Individual_mutate", &mutatAlgLoop, &filesLoop, 10);
//        plotter.plotChronoAveraged(chronoReset, "Individual_reset", &resetAlgLoop, &filesLoop, 10);

        printf("Exit success.\n");
    } catch (std::string& error) {
        cout << "Error: " << error << endl;
    }

    MemoryManagement::printTotalAllocated();
    MemoryManagement::printTotalPointers();
    MemoryManagement::printListOfPointers();

    total.stop();
    printf("Total time spent: %f \n", total.getSeconds());
    return EXIT_SUCCESS;
}
Пример #8
0
			void matrix_plot(const boost::filesystem::path &arg_output_stem, ///< TODOCUMENT
			                 const dyn_prog_score_source   &arg_scorer       ///< TODOCUMENT
			                 ) {
				const size_t length_a = arg_scorer.get_length_a();
				const size_t length_b = arg_scorer.get_length_b();
				P plotter( length_a, length_b, get_window_width_for_full_matrix(length_a, length_b) );
				plotter.plot_scores( arg_scorer );
				plotter.finish( arg_output_stem );
			}
Пример #9
0
int main(int argc, char** argv)
{
  QApplication app(argc, argv);

  PlotterForm plotter(0, "Metrics Plotter");

  app.setMainWidget(&plotter);
  plotter.show();
  return app.exec();
}
Пример #10
0
int main(int argc, char *argv[])
{
    Chronometer total;
    total.start();
    try {
        Util::check(argv[1] == NULL, "You must specify an output directory.");
        ChronoPlotter plotter(argv[1], new RangeLoop(Dummy::SIZE, 512, 8193, 512), "Tiempo (ms)");
        unsigned repetitions = 500;

        plotter.parameters.putNumber(Dummy::WEIGHS_RANGE, 20);
        plotter.parameters.putNumber(Dummy::NUM_INPUTS, 2);
        plotter.parameters.putNumber(Enumerations::enumTypeToString(ET_FUNCTION), FT_IDENTITY);

        EnumLoop linesLoop(ET_IMPLEMENTATION);
        linesLoop.addInnerLoop(new EnumLoop(ET_BUFFER, 3, BT_FLOAT, BT_BIT, BT_SIGN));

        RangeLoop averageLoop(Dummy::OUTPUT_SIZE, 512, 1025, 512);

        plotter.plotChronoAveraged(chronoCalculateAndAddTo, "impl_calculate_inputSize", &linesLoop,
                                   &averageLoop, repetitions);

	repetitions = 1000;
        plotter.resetRangeX(Dummy::OUTPUT_SIZE, 128, 2049, 128);
        averageLoop.setKey(Dummy::SIZE);

        plotter.plotChronoAveraged(chronoCalculateAndAddTo, "impl_calculate_outputSize", &linesLoop,
                                   &averageLoop, repetitions);

        EnumLoop filesLoop(ET_BUFFER, 3, BT_FLOAT, BT_BIT, BT_SIGN);
        EnumLoop cudaLinesLoop(ET_IMPLEMENTATION, 4, IT_CUDA_REDUC0, IT_CUDA_REDUC, IT_CUDA_OUT, IT_CUDA_INV);
        cudaLinesLoop.addInnerLoop(new ExpLoop(CUDA_BLOCK_SIZE, 16, 513, 2));

        plotter.plotChronoFilesAveraged(chronoCalculateAndAddTo, "impl_calculate_outputSize_blockSize", &cudaLinesLoop,
                                   &filesLoop, &averageLoop, repetitions);

	repetitions = 500;
        plotter.resetRangeX(Dummy::SIZE, 512, 8193, 512);
        averageLoop.setKey(Dummy::OUTPUT_SIZE);

        plotter.plotChronoFilesAveraged(chronoCalculateAndAddTo, "impl_calculate_inputSize_blockSize", &cudaLinesLoop,
                                   &filesLoop, &averageLoop, repetitions);

        printf("Exit success.\n");
    } catch (std::string error) {
        cout << "Error: " << error << endl;
    }

    MemoryManagement::printTotalAllocated();
    MemoryManagement::printTotalPointers();
    //MemoryManagement::mem_printListOfPointers();
    total.stop();
    printf("Total time spent: %f \n", total.getSeconds());
    return EXIT_SUCCESS;
}
Пример #11
0
			void matrix_plot(const boost::filesystem::path   &arg_output_stem,              ///< TODOCUMENT
			                 const dyn_prog_score_source     &arg_scorer,                   ///< TODOCUMENT
			                 const return_path_matrix        &arg_return_path_matrix,       ///< TODOCUMENT
			                 const score_accumulation_matrix &arg_score_accumulation_matrix ///< TODOCUMENT
			                 ) {
				const size_t length_a     = arg_return_path_matrix.get_length_a();
				const size_t length_b     = arg_return_path_matrix.get_length_b();
				const size_t window_width = arg_return_path_matrix.get_window_width();
				P plotter( length_a, length_b, window_width );
				plotter.plot_scores( arg_scorer );
				plotter.plot_return_path_matrix( arg_return_path_matrix );
				plotter.plot_accumulated_scores( arg_score_accumulation_matrix );
				plotter.finish( arg_output_stem );
			}
Пример #12
0
// Update values from SOURCE.  Set WAS_CHANGED iff value changed; Set
// WAS_INITIALIZED iff type changed.  Note: Neither THIS nor SOURCE
// can be referenced after calling this function; use the returned
// value instead.
DispValue *DispValue::update(DispValue *source, 
			     bool& was_changed, bool& was_initialized)
{
    assert(source->OK());

    bool was_plotted = (plotter() != 0);

    DispValue *dv = _update(source, was_changed, was_initialized);
    assert(dv->OK());

    if (was_plotted && was_changed)
	dv->plot();

    return dv;
}
Пример #13
0
int main(/*int argc, char* argv[]*/)
{
  // Create OpenGL window in single line
  pangolin::CreateWindowAndBind("Main",640,480);

  // Data logger object
  pangolin::DataLog log;

  // Optionally add named labels
  std::vector<std::string> labels;
  labels.push_back(std::string("sin(t)"));
  labels.push_back(std::string("cos(t)"));
  labels.push_back(std::string("sin(t)+cos(t)"));
  log.SetLabels(labels);

  const float tinc = 0.01f;

  // OpenGL 'view' of data. We might have many views of the same data.
  pangolin::Plotter plotter(&log,0.0f,4.0f*(float)M_PI/tinc,-2.0f,2.0f,(float)M_PI/(4.0f*tinc),0.5f);
  plotter.SetBounds(0.0, 1.0, 0.0, 1.0);
  plotter.Track("$i");

  // Add some sample annotations to the plot
  plotter.AddMarker(pangolin::Marker::Vertical,   -1000, pangolin::Marker::LessThan, pangolin::Colour::Blue().WithAlpha(0.2) );
  plotter.AddMarker(pangolin::Marker::Horizontal,   100, pangolin::Marker::GreaterThan, pangolin::Colour::Red().WithAlpha(0.2) );
  plotter.AddMarker(pangolin::Marker::Horizontal,    10, pangolin::Marker::Equal, pangolin::Colour::Green().WithAlpha(0.2) );

  pangolin::DisplayBase().AddDisplay(plotter);

  float t = 0;

  // Default hooks for exiting (Esc) and fullscreen (tab).
  while( !pangolin::ShouldQuit() )
  {
    glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);

    log.Log(sin(t),cos(t),sin(t)+cos(t));
    t += tinc;

    // Render graph, Swap frames and Process Events
    pangolin::FinishFrame();
  }

  return 0;
}
Пример #14
0
void CalcIncoherentScattering(const long long int iter_num,
                              const double energy_MeV,
                              SharedCompoundPtr target)
{

    // Gen X axis
    int graduation=50;
    double radStep=180.0/(double)graduation;

    std::vector<double> rad;
    double sum=0.0;
    for(int i=0; i<graduation; i++) {
        rad.push_back(sum);
        sum+=radStep;
    }

    // Gen Y axis
    UniformRandomGenerator0to1 random(12345);
    std::vector<double> hist(graduation, 0);
    for(long long int i=0; i<iter_num; i++) {
        RunLight(i,iter_num);
        PointVector_t ray(1.0, 1.0, 1.0);
        SharedPhotonPtr photon = Photon::CreatePhoton(energy_MeV, ray);
        while(photon->IncoherentScattering(target, random) == MC_REJECTED) {}
        for(int j=0; j<graduation; j++) {
            if(photon->GetIncline_rad() < (double)(j *radStep)*M_PI/180.0 ) {
                hist[j]++;
                break;
            }
        }
    }
    double sumhist =std::accumulate(hist.begin(), hist.end(), 0.0);
    for(int i=0; i<hist.size(); i++) {
        hist[i] /=sumhist;
    }

    // Plot
    std::cout << "\r" << "     ";
    std::string mark("*");
    std::string xlabel("degree");
    std::string ylabel("probability");
    Plotter plotter(graduation, 18, xlabel, ylabel);
    plotter.Plot(rad, hist, mark);
}
Пример #15
0
void FacadeGeography::ShowFeature() {
	std::vector<double> width, height;
	for (int i = 0; i < width_; ++i)
	{
		width.push_back(i);
	}
	for (int j = 0; j < height_; ++j)
	{
		height.push_back(j);
	}
	assert(horizonal_feature.size() == width_);
	assert(vertical_feature.size() == height_);
	std::shared_ptr<pcl::visualization::PCLPlotter> plotter(new pcl::visualization::PCLPlotter);
	std::shared_ptr<pcl::visualization::PCLPlotter> plotter2(new pcl::visualization::PCLPlotter);
	plotter->addPlotData(width, horizonal_feature, "Horizontal Feature", vtkChart::LINE);
	plotter2->addPlotData(vertical_feature, height, "Vertical Feature", vtkChart::LINE);

	/*
	std::vector<double> XX, YY;
	XX.push_back(horizontal_wall_parameters[0]);
	XX.push_back(horizontal_wall_parameters[0]);
	YY.push_back(0.0);
	YY.push_back(1.0);
	plotter->addPlotData(XX, YY);

	for (int i = 1; i < horizontal_wall_parameters.size(); ++i)
	{
	int lastx = XX[0];
	XX.clear();
	YY.clear();
	XX.push_back(lastx + horizontal_wall_parameters[i]);
	XX.push_back(lastx + horizontal_wall_parameters[i]);
	YY.push_back(0.0);
	YY.push_back(1.0);

	plotter->addPlotData(XX, YY);
	}
	*/
	plotter->plot();
	plotter2->plot();
}
Пример #16
0
int main( int /*argc*/, char* argv[] )
{
  // Create OpenGL window in single line
  pangolin::CreateWindowAndBind("Main",640,480);

  // Data logger object
  pangolin::DataLog log;

  // Optionally add named labels
  std::vector<std::string> labels;
  labels.push_back(std::string("sin(t)"));
  labels.push_back(std::string("cos(t)"));
  labels.push_back(std::string("sin(t)+cos(t)"));
  log.SetLabels(labels);

  const double tinc = 0.01;

  // OpenGL 'view' of data. We might have many views of the same data.
  pangolin::Plotter plotter(&log,0,4*M_PI/tinc,-2,2,M_PI/(4*tinc),0.5);
  plotter.SetBounds(0.0, 1.0, 0.0, 1.0);
  plotter.Track("$i");

  pangolin::DisplayBase().AddDisplay(plotter);

  float t = 0;

  // Default hooks for exiting (Esc) and fullscreen (tab).
  while( !pangolin::ShouldQuit() )
  {
    glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);

    log.Log(sin(t),cos(t),sin(t)+cos(t));
    t += tinc;

    // Render graph, Swap frames and Process Events
    pangolin::FinishFrame();
  }

  return 0;
}
Пример #17
0
int main()
{
    // Create a plotter
    Plotter plotter("rootfiles/");
    
    // Specify the data histogram, along with a label to be used in the legend
    plotter.AddDataHist("Data", " Data ");
    
    // Specify MC histograms, along with their colours and legend labels
    plotter.AddMCHist("TTbar_Pow", kOrange + 1, " t#bar{t} ");
    plotter.AddMCHist("tW", kRed + 1, " tW ");
    plotter.AddMCHist("WJets", kGray + 1, " W+Jets");
    plotter.AddMCHist("ZZ", kBlue, " ZZ ");  
    plotter.AddMCHist("WZ", kBlue, " WZ ");
    plotter.AddMCHist("DY", kGreen+2, " Z/#gamma* ");
    plotter.AddMCHist("WW", kCyan, " WW ");
    
    // Produce files with pictures
    plotter.Plot("h_met", "em", "Met (GeV/c)",1);
    
    
    return 0;
}
Пример #18
0
int main (int argc, char ** argv) 
{

  gROOT->ProcessLine("#include <vector>");

  char *filename = NULL;
  char *outfname = NULL;
  char *outdname = NULL;
  int c;

  while ((c = getopt (argc, argv, "f:d:o:")) != -1)
    switch (c)
      {
      case 'f':
	filename = optarg;
	break;
     case 'o':
	outfname = optarg;
	break;
      case 'd':
	outdname = optarg;
	break;


      case '?':
	if (optopt == 'f'|| optopt == 'o'|| optopt == 'd')
	  fprintf (stderr, "Option -%c requires an argument.\n", optopt);
	else if (isprint (optopt))
	  fprintf (stderr, "Unknown option `-%c'.\n", optopt);
	else
	  fprintf (stderr,
		   "Unknown option character `\\x%x'.\n",
		   optopt);
	return 1;
      default:
	exit (-1);
      }

  plotterTools plotter(filename,outfname,outdname);

  plotter.setPlotsFormat () ;
  plotter.readInputTree();  
  int nentries = plotter.getTreeEntries();
  plotter.setStepHistoryPlots(20);
  plotter.setGroup("scaler");
  plotter.setModule("beam");
  plotter.bookPlotsScaler(nentries/plotter.getStepHistoryPlots());
  plotter.printHistos();

  plotter.Loop();

  plotter.bookCombinedPlots();

  plotter.plotHistos();
  plotter.saveHistos();
 

  return 0 ;


}
int main() {
	MPlotter plotter("trajectory.txt");
	plotter.run();
	return 0;
}
Пример #20
0
int main(int argc, const char **argv) {
	log_printf(NORMAL, "Starting OpenMOC...");

	double k_eff;
	Timer timer;

	/* Create an options class to parse command line options */
	Options opts(argc, argv);

	/* Set the verbosity */
	log_setlevel(opts.getVerbosity());

	/* Initialize the parser and time the parser */
	timer.start();
	Parser parser(&opts);
	timer.stop();
	timer.recordSplit("Parsing input files");

	/* Initialize the geometry with surfaces, cells & materials */
	timer.reset();
	timer.start();
	Geometry geometry(&parser);
	timer.stop();
	timer.recordSplit("Geomery initialization");

	/* Print out geometry to console if requested at runtime*/
	if (opts.dumpGeometry())
		geometry.printString();

	/* Compress cross-sections if requested at runtime */
	if (opts.compressCrossSections())
		geometry.compressCrossSections();

	Plotter plotter(&geometry, opts.getBitDimension(), opts.getExtension());

	/* Initialize the trackgenerator */
	TrackGenerator track_generator(&geometry, &plotter, opts.getNumAzim(),
				       opts.getTrackSpacing());

	/* Generate tracks */
	timer.reset();
	timer.start();
	track_generator.generateTracks();
	track_generator.makeReflective();
	timer.stop();
	timer.recordSplit("Generating tracks");

	/* Segment tracks */
	timer.reset();
	timer.start();
	track_generator.segmentize();
	timer.stop();
	timer.recordSplit("Segmenting tracks");

	/* Fixed source iteration to solve for k_eff */
	Solver solver(&geometry, &track_generator, &plotter, opts.plotFluxes());
	timer.reset();
	timer.start();
	k_eff = solver.computeKeff(MAX_ITERATIONS);
	timer.stop();
	timer.recordSplit("Fixed source iteration");

	/* Compute pin powers if requested at run time */
	if (opts.computePinPowers())
		solver.computePinPowers();

	log_printf(RESULT, "k_eff = %f", k_eff);

	/* Print timer splits to console */
	log_printf(NORMAL, "Program complete");
	timer.printSplits();
}
Пример #21
0
int main (int argc, char ** argv) {
    
    // check number of input parameters
    if(argc < 2){
        cerr<<"Needs the cfg file as agument --> exit "<<endl;
        return -1;
    }
        
    string cfgName(argv[1]);
    ConfigContainer cfgContainer;
    ConfigHandler* cHandler = nullptr;
    
    try
    {
        cHandler = new ConfigHandler(cfgName, cfgContainer);
        cHandler->readConfig();
        cHandler->writeConfig();
    }
    catch(...)
    {
        cout << "exit program" << endl;
        if(cHandler) delete cHandler;
        return(-1);
    }
    

    EventContainer eventContainer;
    EventReader reader(eventContainer, cfgContainer);
//     EventCleaner cleaner(eventContainer);
    EventSelecter selecter(eventContainer, cfgContainer.cutContainer);
    WeightCalc weightCalc(eventContainer);
    EventPlotter plotter(eventContainer, cfgContainer);
    
    for( unsigned int iSample = 0; iSample < cfgContainer.sampleContainer.reducedNames.size(); ++iSample) 
    {
        // Init fake weights
        if( (cfgContainer.sampleContainer.sampleType[iSample] == SampleType::FAKELEPTON || cfgContainer.sampleContainer.sampleType[iSample] == SampleType::MCFAKELEPTON) && cfgContainer.fakeContainer.fakeElectronFile != "" )
            weightCalc.initFakeWeight(&(cfgContainer.fakeContainer));
        
        for( unsigned int iSubSample = 0; iSubSample < cfgContainer.sampleContainer.sampleNames[iSample].size(); ++iSubSample) 
        {
            // Init DY weights
            if( cfgContainer.flipChargeDY && (cfgContainer.sampleContainer.sampleNames[iSample][iSubSample].find("DY") != string::npos || cfgContainer.sampleContainer.sampleNames[iSample][iSubSample].find("TTTo2L2Nu") != string::npos) )
                weightCalc.initDYWeight(reader);
            
            if( reader.setSample(iSample, iSubSample) )
            {   
                while( reader.fillNextEvent() )
                {
//                     cleaner.doCleaning();
//                     cleaner.doTrackJetsCleaning();
                    if( selecter.passCuts() )
                    {
                        weightCalc.setWeight(cfgContainer.sampleContainer.sampleType[iSample], cfgContainer.sampleContainer.sampleNames[iSample][iSubSample]);
//                         cout << "Event nr:\t" << eventContainer.eventNo() << "\tfake weigth:\t" << eventContainer.weight() << endl;
//                         cout << "lepton 1 pt cor:\t" << eventContainer.looseleptoncorrectedpt(0) << "lepton 2 pt cor:\t" << eventContainer.looseleptoncorrectedpt(1) << endl;
                        plotter.fill(iSample, iSubSample);
                    }
                }
            }
        }
    }
    string filename = "test.root";
    plotter.writeHist(filename);
    plotter.writePlots("png");
    
    delete cHandler;
}
Пример #22
0
void Plotter(TString option = "hist"){

  gInterpreter->ExecuteMacro("../test/PaperStyle.C");

  float lumi = lumi_fb_Full2016/15;

  Bool_t scale = logY;

  HistogramReader plotter(inputdir, outputdir);

  plotter.SetStackOption(option);
  plotter.SetPublicStyle(false);
  plotter.SetSavePdf    (true);

  if (option.Contains("nostack"))
    {
      plotter.SetDrawRatio(false);     
    }
  else
    {
      plotter.SetLuminosity(lumi);
      plotter.SetDrawRatio (true);
    }    


  // Get the data
  //----------------------------------------------------------------------------
  plotter.AddData("01_Data_1outof15", "data", color_Data);
  //plotter.AddData("01_Data_reduced_1outof6", "data", color_Data);

  // Add processes
  //----------------------------------------------------------------------------
  //plotter.AddProcess("14_HZ",        "HZ",         color_HZ);
  //plotter.AddProcess("10_HWW",       "HWW",        color_HWW);
  plotter.AddProcess("06_WW",        "WW",         color_WW, roc_background);//, 1.030108192);
  plotter.AddProcess("02_WZTo3LNu",  "WZ",         color_WZTo3LNu, roc_background);//, 1.030108192);
  plotter.AddProcess("03_VZ",        "VZ",         color_VZ, roc_background);//, 1.030108192);
  plotter.AddProcess("13_VVV",       "VVV",        color_VVV, roc_background);//, 1.030108192);
  plotter.AddProcess("11_Wg",        "W#gamma",    color_Wg, roc_background);//, 1.030108192);
  //plotter.AddProcess("15_WgStar",    "W#gamma*",   color_WgStar);
  plotter.AddProcess("07_ZJets",     "Z+jets",     color_ZJets, roc_background);//, 1.030108192);
  plotter.AddProcess("09_TTV", "ttV",        color_TTV, roc_background);//, 1.030108192);
  plotter.AddProcess("04_TTTo2L2Nu", "tt",         color_TTTo2L2Nu, roc_background);//, 1.030108192);
  plotter.AddProcess("05_ST",        "tW",         color_ST, roc_background);//, 1.030108192);
  plotter.AddProcess("00_Fakes_1outof15",     "non-prompt", color_Fakes, roc_background, -999); // -999 is needed to not scale by luminosity


  // Add signals
  //----------------------------------------------------------------------------
  //plotter.AddSignal("ttDM0001scalar00010", "m_{#chi}1 m_{S}10 x10",  color_Signal, roc_signal, 10);
  //plotter.AddSignal("ttDM0001scalar00020", "m_{#chi}1 m_{S}20",  color_Signal+2, roc_signal);
  //plotter.AddSignal("ttDM0001scalar00050", "m_{#chi}1 m_{S}50",  color_Signal+4, roc_signal);
  //plotter.AddSignal("ttDM0001scalar00100", "m_{#chi}1 m_{S}100", color_Signal+2, roc_signal);
  //plotter.AddSignal("ttDM0001scalar00200", "m_{#chi}1 m_{S}200", color_Signal, roc_signal);
  //plotter.AddSignal("ttDM0001scalar00300", "m_{#chi}1 m_{S}300", color_Signal, roc_signal);
  //plotter.AddSignal("ttDM0001scalar00500", "m_{#chi}1 m_{S}500 x10^{3}", color_Signal+4, roc_signal, 1000);


  // Add systematics
  //----------------------------------------------------------------------------
  //plotter.AddSystematic("Btagup");	

  // Draw distributions
  //----------------------------------------------------------------------------
  if (!option.Contains("nostack")) plotter.SetDrawYield(true);

  gSystem->mkdir(outputdir, kTRUE);

  TString title = "cms";

  plotter.SetTitle(title);


  //            hname              xtitle                     ngroup precision units  setlogy moveoverflow xmin xmax ymin ymax
  // -------------------------------------------------------------------------------------------------------------------------
  ///plotter.Draw( "darkpt"         , "(reconstructed) mediator p_{T}",      5, 0, "GeV",  scale, false, -100, 800, 1 );
  //plotter.Draw( "dphijet1met"    , "#Delta#phi(jet1,E_{T}^{miss})",      5, 2, "rad",  scale, false);
  //plotter.Draw( "dphijet2met"    , "#Delta#phi(jet2,E_{T}^{miss})",      5, 2, "rad",  scale, false);
  //plotter.Draw( "dphijj"         , "#Delta#phi(jet1,jet2)",              5, 2, "rad",  scale, false);
  //plotter.Draw( "dphijjmet"      , "#Delta#phi(jj,E_{T}^{miss})",        5, 2, "rad",  scale, false);
  //plotter.Draw( "dphilep1jet1"   , "#Delta#phi(lep1,jet1)",              5, 2, "rad",  scale, false);
  //plotter.Draw( "dphilep1jet2"   , "#Delta#phi(lep1,jet2)",              5, 2, "rad",  scale, false);
  //plotter.Draw( "dphilep2jet1"   , "#Delta#phi(lep2,jet1)",              5, 2, "rad",  scale, false);
  //plotter.Draw( "dphilep2jet2"   , "#Delta#phi(lep2,jet2)",              5, 2, "rad",  scale, false);
  //plotter.Draw( "dphill"         , "#Delta#phi(lep1,lep2)",              5, 2, "rad",  scale, false);
  ///plotter.Draw( "dphillmet"      , "#Delta#phi(" +sll + "," + sm + ")",  5, 2, "rad",  scale, true, 0, 3.2, 1);
  //plotter.Draw( "dphilmet1"      , "#Delta#phi(lep1,E_{T}^{miss})",      5, 2, "rad",  scale, false);
  //plotter.Draw( "dphilmet2"      , "#Delta#phi(lep2,E_{T}^{miss})",      5, 2, "rad",  scale, false);
  ///plotter.Draw( "ht"             , "H_{T}",                             20, 0, "GeV",  scale, true, 0, 1500, 1);
  //plotter.Draw( "htjets"         , "#sum_{jet} p_{T}",                  20, 0, "GeV",  scale, true, 0, 1500);
  //plotter.Draw( "htnojets"       , "p_{T}^{lep1} + p_{T}^{lep2} + MET", 20, 0, "GeV",  scale, true, 0, 1500);
  //plotter.Draw( "jet1eta"        , "leading jet #eta",                  -1, 1, "NULL", scale, false);
  //plotter.Draw( "jet1mass"       , "leading jet mass",                  -1, 0, "GeV",  scale, true, 0,   50);
  //plotter.Draw( "jet1phi"        , "leading jet #phi",                   5, 2, "rad",  scale, false);
  ///plotter.Draw( "jet1pt"         , "leading jet p_{T}",                  5, 0, "GeV",  scale, true, 0,  400, 1);
  //plotter.Draw( "jet2eta"        , "trailing jet #eta",                 -1, 1, "NULL", scale, false);
  //plotter.Draw( "jet2mass"       , "trailing jet mass",                 -1, 0, "GeV",  scale, true, 0,   50);
  //plotter.Draw( "jet2phi"        , "trailing jet #phi",                  5, 2, "rad",  scale, false);
  ///plotter.Draw( "jet2pt"         , "trailing jet p_{T}",                 5, 0, "GeV",  scale, true, 0,  400, 1);
  //plotter.Draw( "lep1eta"        , "leading lepton #eta",               -1, 1, "NULL", scale);
  //plotter.Draw( "lep1phi"        , "leading lepton #phi",                5, 2, "rad",  scale);
  ///plotter.Draw( "lep1pt"         , "leading lepton p_{T}",               5, 0, "GeV",  scale, true, 0,  150, 1);
  //plotter.Draw( "lep2eta"        , "trailing lepton #eta",              -1, 1, "NULL", scale);
  //plotter.Draw( "lep2phi"        , "trailing lepton #phi",               5, 2, "rad",  scale);
  ///plotter.Draw( "lep2pt"         , "trailing lepton p_{T}",              5, 0, "GeV",  scale, true, 0,  150, 1);
  ///plotter.Draw( "m2l"            , "m_{" + sll + "}",                   10, 0, "GeV",  scale, true, 0,  300, 1);
  plotter.Draw( "metPfType1"     , sm,                                  10, 0, "GeV",  scale, true, 0,  200, 1);
  //plotter.Draw( "mt2lblb"        , "M_{T2}(" + sl + "b" + sl + "b)",    10, 0, "GeV",  scale, false, 0, 600);
  ///plotter.Draw( "mt2ll"          , "M_{T2}(" + sll + ")",               10, 0, "GeV",  scale, false, 0, 200, 0.1); 
  //plotter.Draw( "mtw1"           , "m_{T}^{W,1}",                       10, 0, "GeV",  scale, true, 0,  400);
  //plotter.Draw( "mtw2"           , "m_{T}^{W,2}",                       10, 0, "GeV",  scale, true, 0,  400);
  ///plotter.Draw( "nbjet30csvv2m"  , "number of 30 GeV csvv2m b-jets",    -1, 0, "NULL", scale, true, 0,  6, 1);
  ///plotter.Draw( "njet"           , "number of 30 GeV jets",             -1, 0, "NULL", scale, true, 0,  10, 1);
  ///plotter.Draw( "nvtx"           , "number of vertices",                -1, 0, "NULL", linY,  true, 0,   30, 1);
  //plotter.Draw( "ntrueint"       , "number of true interactions",       -1, 0, "NULL", linY,  true, 0,   30, 1);
  //plotter.Draw( "topRecoW"       , "top reco weight",                  -1, 4, "NULL", scale, true, 0,  0.01);
  //plotter.Draw( "ANN_tanh_mt2ll80_regina_ttDM0001scalar00010", "ANN output", 5, 2, "NULL", scale, true, 0, 1.0, 1);
  //plotter.Draw( "ANN_sigm_mt2ll100_ttDM0001scalar00500", "ANN output", 2, 2, "NULL", scale, true, 0, 1.0);

  //plotter.Roc( "ANN_tanh_mt2ll100_ttDM0001scalar00500", "ANN output"    , 60, "GeV", -0.1, 1.1);
  //plotter.Roc( "ANN_sigm_mt2ll80_regina_ttDM0001scalar00010", "ANN output"    , 60, "GeV", -0.1, 1.1);
  //plotter.Draw( "scale"           , "- u_{||} / q_{T}",                -1, 0, "NULL", scale,  true, -3, 5, 1, 1e8 );
  //plotter.Draw( "uPara"           , "u_{||} + q_{T}",                  -1, 0, "GeV", scale,  true, -200, 200, 1, 1e8 );
  //plotter.Draw( "uPerp"           , "u_{#perp}",                       -1, 0, "GeV", scale,  true, -200, 200, 1, 1e8 );

  //           hname     xtitle                      npoints  units xmin xmax
  //  ---------------------------------------------------------------------------

  //plotter.Roc( "lep1pt", "leading lepton p_{T}",        1000, "GeV", 0, 1000);
  //plotter.Roc( "mt2ll", "M_{T2}(" + sll + ")",            1000, "GeV", 0, 500, "Punzi Eq.6");
  //plotter.Roc( "mt2ll", "M_{T2}(" + sll + ")",            1000, "GeV", 0, 500);

  //plotter.Roc( "dphillmet", "#Delta#phi(" +sll + "," + sm + ")",            1000, "GeV", 2, 5, "Punzi Eq.6");
  //plotter.Roc( "dphillmet", "#Delta#phi(" +sll + "," + sm + ")",            1000, "GeV", 2, 5);
  
  //plotter.Roc( "metPfType1", sm,            1000, "GeV", 0, 200, "Punzi Eq.6");
  //plotter.Roc( "metPfType1", sm,            1000, "GeV", 0, 200);

  //plotter.Roc( "ht", "H_{T}",            1000, "GeV", 0, 1500, "Punzi Eq.6");
  //plotter.Roc( "ht", "H_{T}",            1000, "GeV", 0, 1500);

  //plotter.Roc("topRecoW", "topRecoW", 1000, "NULL", 0, 0.01, "Punzi Eq.6");
  //plotter.Roc("topRecoW", "topRecoW", 1000, "NULL", 0, 0.01);

  //plotter.Roc( "darkpt"    , "(reconstructed) mediator p_{T}"       , 80, "GeV",0, 800);
  //plotter.Roc( "metPfType1", sm                   , 100, "GeV", 0, 200);
  //plotter.Roc( "mt2ll"     , "M_{T2}(" + sll + ")", 50, "GeV", 0, 150);
  //plotter.Roc( "topRecoW"  , "top reco weight"    , 100, "GeV", 0, .01);

  
  // Copy index.php in every directory
  //----------------------------------------------------------------------------
  gSystem->Exec("for dir in $(find ./ -type d); do cp -n ../index.php $dir/; done");
  gSystem->Exec("rm -f index.php");

}
Пример #23
0
int main(int argc, char **argv){

#ifdef WIN32
    WSADATA wsaData; // if this doesn't work
    //WSAData wsaData; // then try this instead

    if (WSAStartup(MAKEWORD(1, 1), &wsaData) != 0) {
        fprintf(stderr, "WSAStartup failed.\n");
        exit(1);
    }
#endif

    int hand_shake_listen_port_no = 19999;
    char* absolute_file_path = NULL;
    char* packet_file_path = NULL;
    char* colour_file_path = NULL;
    char* remote_host = NULL;

    for (int arg_index = 1; arg_index < argc; arg_index+=2){

        if (strcmp(argv[arg_index], "-hand_shake_port") == 0){
            hand_shake_listen_port_no = atoi(get_next_arg(arg_index, argv, argc));
        }
        if (strcmp(argv[arg_index], "-database") == 0){
            absolute_file_path = get_next_arg(arg_index, argv, argc);
        }
        if (strcmp(argv[arg_index], "-colour_map") == 0){
            colour_file_path = get_next_arg(arg_index, argv, argc);
        }
        if (strcmp(argv[arg_index], "-remote_host") == 0) {
            remote_host = get_next_arg(arg_index, argv, argc);
        }
    }

    if (colour_file_path == NULL) {
        printf("Usage is \n "
               "-colour_map "
               "<Path to a file containing the population labels to receive,"
               " and their associated colours>\n"
               "[-hand_shake_port]"
               "<optional port which the visualiser will listen to for"
               " database hand shaking>\n"
               "[-database]"
               "<optional file path to where the database is located,"
               " if needed for manual configuration>\n"
               "[-remote_host] "
               "<optional remote host, which will allow port triggering>\n");
        return 1;
    }

    DatabaseMessageConnection *database_message_connection = NULL;
    if (absolute_file_path == NULL) {
        database_message_connection = new DatabaseMessageConnection(
            hand_shake_listen_port_no);
        printf("awaiting tool chain hand shake to say database is ready \n");
        packet_file_path = database_message_connection->recieve_notification();
        printf("received tool chain hand shake to say database is ready \n");
    }

    // Open the database
    DatabaseReader* database = NULL;
    if (!absolute_file_path){
        printf("using packet based address \n");
        database = new DatabaseReader(packet_file_path);
    } else {
        printf("using command based address \n");
        database = new DatabaseReader(absolute_file_path);
    }

    // Get the details of the populations to be visualised
    ColourReader *colour_reader = new ColourReader(colour_file_path);
    std::vector<char *> *labels = colour_reader->get_labels();

    // Read the database and store the results in a useful form
    std::map<int, char*> *y_axis_labels = new std::map<int, char*>();
    std::map<int, int> *key_to_neuronid_map = new std::map<int, int>();
    std::map<int, colour> *neuron_id_to_colour_map =
            new std::map<int, colour>();
    std::set<int> *ports_to_listen_to = new std::set<int>();
    int base_neuron_id = 0;
    for (std::vector<char *>::iterator iter = labels->begin();
            iter != labels->end(); iter++) {
        char *label = *iter;
        fprintf(stderr, "Reading %s\n", label);

        // Get the port details
        ip_tag_info *tag = database->get_live_output_details(label);
        ports_to_listen_to->insert(tag->port);
        free(tag);

        // Get the key to neuron id for this population and the colour
        std::map<int, int> *key_map =
            database->get_key_to_neuron_id_mapping(label);
        colour col = colour_reader->get_colour(label);

        // Add the keys to the global maps, adding the current base neuron id
        for (std::map<int, int>::iterator key_iter = key_map->begin();
                key_iter != key_map->end(); key_iter++) {
            int nid = key_iter->second + base_neuron_id;
            (*key_to_neuronid_map)[key_iter->first] = nid;
            (*neuron_id_to_colour_map)[nid] = col;
        }
        delete key_map;

        // Put the label half-way up the population
        int n_neurons = database->get_n_neurons(label);
        (*y_axis_labels)[base_neuron_id + (n_neurons / 2)] = label;

        // Add to the base neurons for the next population (plus a spacer)
        base_neuron_id += n_neurons + 10;
    }

    // Get other parameters
    float run_time = database->get_configuration_parameter_value(
        (char *) "runtime");
    float machine_time_step = database->get_configuration_parameter_value(
        (char *) "machine_time_step") / 1000.0;

    // Close the database
    database->close_database_connection();
    delete database;

    // Create the visualiser
    RasterPlot plotter(
        argc, argv, remote_host, ports_to_listen_to, y_axis_labels,
        key_to_neuronid_map, neuron_id_to_colour_map, run_time,
        machine_time_step, base_neuron_id, database_message_connection);
    return 0;
}
Пример #24
0
int main (int argc, char ** argv) 
{

  gROOT->ProcessLine("#include <vector>");

  string ROOT_FOLDER ="";
  string OUT_FOLDER  ="";
  string run="";
  string spill="";
  string integratedfname ="";

  int c;
  while ((c = getopt (argc, argv, "i:o:r:s:I:")) != -1)
    switch (c)
      {
      case 'i':
	ROOT_FOLDER = string(optarg);
	break;
     case 'o':
       OUT_FOLDER =  string(optarg);
	break;
      case 'r':
	run =  string(optarg);
	break;
      case 's':
	spill =  string(optarg);
	break;
      case 'I':
	integratedfname= string(optarg);
	break;

      case '?':
	if (optopt == 'i'|| optopt == 'o'|| optopt == 'r'|| optopt == 's'||optopt == 'I')
	  fprintf (stderr, "Option -%c requires an argument.\n", optopt);
	else if (isprint (optopt))
	  fprintf (stderr, "Unknown option `-%c'.\n", optopt);
	else
	  fprintf (stderr,
		   "Unknown option character `\\x%x'.\n",
		   optopt);
	return 1;
      default:
	exit (-1);
      }

  string filename=ROOT_FOLDER+"/"+run+"/"+spill+".root";
  string outdname=OUT_FOLDER+"/"+run+"/"+spill+"/hodo/";
  string outfname=outdname+"dqmPlots"+"hodo"+".root";
  string integratedName=OUT_FOLDER+"/"+run+"/"+integratedfname;

  system( Form("mkdir -p %s", outdname.c_str()) );


  std::cout<<filename<<" "<<outdname<<" "<<outfname<<" "<<integratedfname<<endl;

  plotterTools plotter(filename,outfname,outdname);

  plotter.setPlotsFormat () ;
  plotter.readInputTree();  
  int nentries = plotter.getTreeEntries();
  plotter.setStepHistoryPlots(20);
  plotter.setGroup("hodo");
  plotter.setModule("beam");
  plotter.bookPlotsHodo(nentries/plotter.getStepHistoryPlots());
  plotter.bookPlotsSmallHodo(nentries/plotter.getStepHistoryPlots());
  plotter.printHistos();

  plotter.Loop();

  if(integratedfname != "")  plotter.initIntegrated(integratedName); 

  plotter.fitHisto("beamPositionX1","gaus");
  plotter.fitHisto("beamPositionX2","gaus");
  plotter.fitHisto("beamPositionY1","gaus");
  plotter.fitHisto("beamPositionY2","gaus");
  plotter.fitHisto("beamPositionX","gaus");
  plotter.fitHisto("beamPositionY","gaus");

  plotter.fitHisto("beamPositionSmallX","gaus");
  plotter.fitHisto("beamPositionSmallY","gaus");


  plotter.bookCombinedPlotsHodo();

  plotter.plotHistos();
  plotter.saveHistos();
 


  return 0 ;


}
Пример #25
0
/*!

   Connect to Pepper robot, and apply some motion.
   By default, this example connect to a robot with ip address: 198.18.0.1.
   If you want to connect on an other robot, run:

   ./motion --ip <robot ip address>

   Example:

   ./motion --ip 169.254.168.230
 */
int main(int argc, const char* argv[])
{
  try
  {
    std::string opt_ip = "198.18.0.1";;

    if (argc == 3) {
      if (std::string(argv[1]) == "--ip")
        opt_ip = argv[2];
    }

    vpNaoqiRobot robot;
    if (! opt_ip.empty()) {
      std::cout << "Connect to robot with ip address: " << opt_ip << std::endl;
      robot.setRobotIp(opt_ip);
    }

    robot.open();

    std::vector<std::string> names = robot.getBodyNames("Body");
    std::vector<float> values(names.size(),0.0);
    robot.getProxy()->setMoveArmsEnabled(false,false);
    robot.getPosition(names,values,false);

    bool servoing = true;

    // Define values
    float y = 1.0; //
    float ell1 = 2.0; //
    float ell2 = 2.0; //
    float ell = 2.0;
    float d = 0.7; //
    float x = 0.0;
    vpMatrix L(1,6);

    L = 0.0;

    //float lambda = 0.03;
    float lambda = 0.1;//0.09; // 0.050;

    vpColVector s(1);
    vpColVector s_star(1);
    s_star[0] = 3.;// 1.;
    vpColVector vel(6);
    vpColVector vel_(3);
    //    vpMatrix J (6,6);
    //    J =0.0;
    //    j[]


    AL::ALMemoryProxy memProxy(opt_ip, 9559);

    bool start = false;

    vpImage<unsigned char> I(320, 320);
    vpDisplayX dd(I);
    vpDisplay::setTitle(I, "ViSP viewer");
    vpDisplay::setWindowPosition(I,1200,900);


    vpLinearKalmanFilterInstantiation kalman;

    double rho=0.3;
    vpColVector sigma_state;
    vpColVector sigma_measure(1);
    int signal = 1;

    kalman.setStateModel(vpLinearKalmanFilterInstantiation::stateConstAccWithColoredNoise_MeasureVel);
    //kf.init(nbSrc,nbSrc,nbSrc);
    int state_size = kalman.getStateSize();
    sigma_state.resize(2);
    sigma_state= 0.00001; // Same variance for all the signals
    sigma_measure = 0.05; // Same measure variance for all the signals
    double dt = 0.172;
    kalman.initFilter(signal, sigma_state , sigma_measure, rho, dt );
    kalman.verbose(true);



    vpLinearKalmanFilterInstantiation kalman1;


    kalman1.setStateModel(vpLinearKalmanFilterInstantiation::stateConstAccWithColoredNoise_MeasureVel);
    //kf.init(nbSrc,nbSrc,nbSrc);
    sigma_state.resize(2);
    sigma_state= 0.00001; // Same variance for all the signals
    sigma_measure = 0.05; // Same measure variance for all the signals
    kalman1.initFilter(signal, sigma_state , sigma_measure, rho, dt );
    kalman1.verbose(true);


    vpPlot plotter (2);
    plotter.initGraph(0, 1);
    plotter.initGraph(1, 2);
    //plotter_eyes.initGraph(2, 1);
    //plotter_eyes.initGraph(3, 1);
    plotter.setTitle(0,  "Ratio");
    plotter.setTitle(1,  "Error");
    //plotter_eyes.setTitle(2,  "REyeYaw");
    //plotter_eyes.setTitle(3,  "REyePitch");

    vpPlot plotter_kal (1);
    plotter_kal.initGraph(0, 2);
    //plotter_eyes.initGraph(2, 1);
    //plotter_eyes.initGraph(3, 1);
    plotter_kal.setTitle(0,  "Ratio");
    plotter_kal.setLegend(0, 0, "Ratio");
    plotter_kal.setLegend(0, 1, "Ratio kal");


    //    vpPlot plotter_e (1);
    //    plotter_e.initGraph(0, 2);

    //    plotter_e.setLegend(0, 0, "Right");
    //    plotter_e.setLegend(0, 1, "Left");

    //    plotter_e.setTitle(0,  "Energy");


    vpPlot plotter_vel (1);
    plotter_vel.initGraph(0, 3);
    plotter_vel.setTitle(0,  "Velocity");
    plotter_vel.setLegend(0, 0, "vx");
    plotter_vel.setLegend(0, 1, "vy");
    plotter_vel.setLegend(0, 2, "wz");

    unsigned long loop_iter = 0;

    while (1)
    {
      std::cout << "----------------------------------" << std::endl;
      double t = vpTime::measureTimeMs();
      float ratio = memProxy.getData("ALSoundProcessing/ratioRightLeft");

      float sound_detected = memProxy.getData("ALSoundProcessing/soundDetectedEnergy");
      std::cout << "SoundDetected:" << sound_detected << std::endl;

      if ( (sound_detected > 0.5) && !start)
        start = true;

      if (start)
      {

        float E1 = memProxy.getData("ALSoundProcessing/rightMicEnergy");
        float E2= memProxy.getData("ALSoundProcessing/leftMicEnergy");

        E1 = E1/1e9;
        E2 = E2/1e9;

        //        plotter_e.plot(0, 0,loop_iter, float( memProxy.getData("ALSoundProcessing/rightMicEnergy")));
        //        plotter_e.plot(0, 1,loop_iter, float(  memProxy.getData("ALSoundProcessing/leftMicEnergy")));

        //  plotter.plot(0, 1, loop_iter,ratio);


        float c_x=d/2.*(E1+E2)/(E1-E2);
        float c_r=std::abs((d*(sqrt(E1*E2)/(E1-E2)))) ;
        ell=2.;//sqrt(sqrt(sqr(d*c_x))-d*d/4.+1);
        ell1=sqrt((c_x-d/2)*(c_x-d/2) + c_r * c_r);
        ell2=sqrt((c_x+d/2)*(c_x+d/2) + c_r * c_r);
        //float Em=4.*E1*ell1*ell1/(2*ell1*ell1+2*ell2*ell2-d*d);
        c_x=c_x/abs(c_x);
        //x=c_x;
        if (ratio >= 1.)
          x = 2;
        else
          x = -2;
        y=1;//c_r;
        std::cout<<"ell:"<<ell<<std::endl;

        vpColVector ratio_v(1);
        ratio_v[0] = ratio;
        //ratio_v[1] = Em;
        kalman.filter(ratio_v);
        std::cout << "Estimated x velocity: kalman.Xest[0]" <<  kalman.Xest[0]<< std::endl;
        std::cout << "Estimated x velocity: kalman.Xest[1]" <<  kalman.Xest[1]<< std::endl;

        plotter_kal.plot(0, 0, loop_iter, ratio);

        ratio = (4*ratio + 3*kalman.Xest[0])/7;

        plotter_kal.plot(0, 1, loop_iter, ratio);

        // Compute Interaction matrix
        L[0][0]= (2*x*(ratio-1)-d*(1+ratio))/(ell*ell-d*x+d*d/4.);
        L[0][1]=(2*y*(ratio-1))/(ell*ell-d*x+d*d/4.);
        L[0][5]=(y*d*(ratio+1))/(ell*ell-d*x+d*d/4.);

        s[0] = ratio;
        std::cout << "L: " << L << std::endl;

        //lambda = 0.0216404* log(1+abs(ratio - s_star));
        //Compute joint velocity NeckYaw
        vpColVector e = (s-s_star);
        vel =-lambda*L.pseudoInverse()*e;/* Compute V_m*/


        std::cout << "e :" << e << std::endl;
        vel_[0] = vel[1];
        vel_[1] = -vel[0];
        vel_[2] = vel[5];

        plotter_vel.plot(0, 0, loop_iter, vel_[0]);
        plotter_vel.plot(0, 1, loop_iter, vel_[1]);
        plotter_vel.plot(0, 2, loop_iter, vel_[2]);


        plotter.plot(0, 0, loop_iter,ratio);
        plotter.plot(1, 0, loop_iter,e[0]);


        std::cout << "vel: " << vel << std::endl;

        if (servoing)
        {
          robot.getProxy()->move(vel_[0],vel_[1],vel_[2]);
          robot.getProxy()->setAngles(names,values,1.0);
        }
      }

      // Save current values

      loop_iter ++;

      vpTime::sleepMs(170);

      std::cout << "Loop time: " << vpTime::measureTimeMs() - t << " ms" << std::endl;

      if (vpDisplay::getClick(I, false))
        break;
    }

    robot.getProxy()->move(0.0,0.0,0.0);
    //   plotter->saveData(0, "ratio.dat");



    vpDisplay::getClick(I, true);
    plotter_kal.saveData(0, "ratio.dat");
    //    plotter_kal.saveData(1,"em.dat");
    plotter_vel.saveData(0, "vel.dat");

  }
  catch (const vpException &e)
  {
    std::cerr << "Caught exception: " << e.what() << std::endl;
  }
  catch (const AL::ALError &e)
  {
    std::cerr << "Caught exception: " << e.what() << std::endl;
  }



  return 0;
}
Пример #26
0
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
//
// runPlotter
//
// option = "hist"         --> all distributions normalized to the luminosity
// option = "nostack,hist" --> signal and top distributions normalized to one
//
//   Draw(TString  hname,                  Name of the histogram.
//        TString  xtitle       = "",      Title of the x-axis.
//        Int_t    ngroup       = -1,      Number of bins to be merged into one bin.
//        Int_t    precision    = 0,       Number of decimal digits.
//        TString  units        = "NULL",  Units of the histogram.
//        Bool_t   setlogy      = false,   Set it to true (false) for logarithmic (linear) scale.
//        Bool_t   moveoverflow = true,    Set it to true to plot the events out of range.
//        Float_t  xmin         = -999,
//        Float_t  xmax         = -999,
//        Float_t  ymin         = -999,
//        Float_t  ymax         = -999);
//
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
void runPlotter(TString level,
		TString option = "hist")
{
  gInterpreter->ExecuteMacro("PaperStyle.C");

  TString tok;

  Ssiz_t from = 0;

  TString analysis = (level.Tokenize(tok, from, "/")) ? tok : "NONE";

  if (analysis.EqualTo("NONE")) return;

  float lumi = lumi_fb_2016;

  if (analysis.EqualTo("Shape")) lumi = lumi_fb_Run2016B;

  Bool_t scale = linY;

  if (analysis.EqualTo("MonoH")) scale = logY;
  if (analysis.EqualTo("Stop"))  scale = logY;
  if (analysis.EqualTo("Top"))   scale = logY;

  int firstchannel = (analysis.EqualTo("WZ")) ? eee : ee;
  int lastchannel  = (analysis.EqualTo("WZ")) ? lll : ll;

  HistogramReader plotter(inputdir + analysis, outputdir);

  plotter.SetStackOption(option);
  plotter.SetPublicStyle(false);
  plotter.SetSavePdf    (false);

  if (option.Contains("nostack"))
    {
      plotter.SetDrawRatio(false);
    }
  else
    {
      plotter.SetLuminosity(lumi);
      plotter.SetDrawRatio (true);
    }


  // Get the data
  //----------------------------------------------------------------------------
  plotter.AddData("01_Data", "data", color_Data);


  // Add processes
  //----------------------------------------------------------------------------
  if (analysis.EqualTo("WZ"))
    {
      plotter.AddProcess("02_WZTo3LNu", "WZ",       color_WZTo3LNu);
      plotter.AddProcess("06_WW",       "WW",       color_WW);
      plotter.AddProcess("11_Wg",       "W#gamma",  color_Wg);
      plotter.AddProcess("15_WgStat",   "W#gamma*", color_WgStar);
      plotter.AddProcess("03_VZ",       "VZ",       color_VZ);
      plotter.AddProcess("09_TTV",      "ttV",      color_TTV);
      plotter.AddProcess("13_VVV",      "VVV",      color_VVV);

      if (datadriven)
	{
	  // -999 is needed to not scale by luminosity
	  plotter.AddProcess("00_Fakes", "non-prompt", color_Fakes, roc_background, -999);
	  plotter.AddProcess("12_Zg",    "Z#gamma",    color_Zg);
	}
      else
	{
	  plotter.AddProcess("07_ZJets",     "Z+jets", color_ZJets);
	  plotter.AddProcess("04_TTTo2L2Nu", "tt",     color_TTTo2L2Nu);
	  plotter.AddProcess("05_ST",        "tW",     color_ST);
	}
    }
  else
    {
      plotter.AddProcess("14_HZ",        "HZ",       color_HZ);
      plotter.AddProcess("10_HWW",       "HWW",      color_HWW);
      plotter.AddProcess("06_WW",        "WW",       color_WW, roc_signal);
      plotter.AddProcess("02_WZTo3LNu",  "WZ",       color_WZTo3LNu);
      plotter.AddProcess("03_VZ",        "VZ",       color_VZ);
      plotter.AddProcess("11_Wg",        "W#gamma",  color_Wg);
      plotter.AddProcess("15_WgStar",    "W#gamma*", color_WgStar);
      plotter.AddProcess("07_ZJets",     "Z+jets",   color_ZJets);
      plotter.AddProcess("09_TTV",       "ttV",      color_TTV);
      plotter.AddProcess("04_TTTo2L2Nu", "tt",       color_TTTo2L2Nu);
      plotter.AddProcess("05_ST",        "tW",       color_ST);

      if (datadriven)
	{
	  // -999 is needed to not scale by luminosity
	  plotter.AddProcess("00_Fakes", "non-prompt", color_Fakes, roc_background, -999);
	}
      else
	{
	  plotter.AddProcess("08_WJets", "W+jets", color_WJets);
	}
    }


  // Add signals
  //----------------------------------------------------------------------------
  if (analysis.EqualTo("MonoH"))
    {
      plotter.AddSignal("monoH_2HDM_MZp-600_MA0-400",  "m_{Z'} 600",  color_Signal-4);
      plotter.AddSignal("monoH_2HDM_MZp-800_MA0-400",  "m_{Z'} 800",  color_Signal-3);
      plotter.AddSignal("monoH_2HDM_MZp-1200_MA0-400", "m_{Z'} 1200", color_Signal-1);
      plotter.AddSignal("monoH_2HDM_MZp-1700_MA0-400", "m_{Z'} 1700", color_Signal+1);
      plotter.AddSignal("monoH_2HDM_MZp-2000_MA0-400", "m_{Z'} 2000", color_Signal+2);
      plotter.AddSignal("monoH_2HDM_MZp-2500_MA0-400", "m_{Z'} 2500", color_Signal+3);
    }


  if (analysis.EqualTo("TTDM"))
    {
      plotter.AddSignal("ttDM0001scalar00010", "m_{#chi}1 m_{S}10",  color_Signal);
      plotter.AddSignal("ttDM0001scalar00500", "m_{#chi}1 m_{S}500", color_Signal+2);
    }


  if (analysis.EqualTo("Stop"))
    {
      plotter.AddSignal("T2tt_mStop??", "m_{Stop}350-400",  color_Signal);  
      plotter.AddSignal("T2tt_mStop??", "m_{Stop}400-1200", color_Signal+2);  
    }


  // Draw events by cut
  //----------------------------------------------------------------------------
  plotter.SetDrawYield(false);

  gSystem->mkdir(outputdir + level, kTRUE);

  for (int i=firstchannel; i<=lastchannel; i++)
    {
      plotter.LoopEventsByCut(analysis, "h_counterLum_" + schannel[i]);

      TString title = (i < lastchannel) ? lchannel[i] : "inclusive";

      plotter.SetTitle(title);

      plotter.Draw(analysis + "/h_counterLum_" + schannel[i] + "_evolution", "", -1, 0, "NULL", logY, false);
    }


  // Draw events by channel
  //----------------------------------------------------------------------------
  plotter.SetDrawYield(false);

  for (int j=0; j<=njetbin; j++)
    {
      if (!analysis.EqualTo("Top")  &&
	  !analysis.EqualTo("Stop") &&
	  !analysis.EqualTo("WW")   &&
	  j != njetbin) continue;
      
      TString jetbin = (j < njetbin) ? Form("/%djet", j) : "";

      gSystem->mkdir(outputdir + level + jetbin, kTRUE);

      plotter.LoopEventsByChannel(level + jetbin);

      plotter.Draw(level + jetbin + "/h_counterLum_evolution", "", -1, 0, "NULL", scale, false);
    }


  // Draw distributions
  //----------------------------------------------------------------------------
  if (!option.Contains("nostack")) plotter.SetDrawYield(true);
  if (analysis.EqualTo("MonoH"))   plotter.SetDrawYield(false);

  float m2l_xmin   = (level.Contains("WZ")) ?  60 :   0;  // [GeV]
  float m2l_xmax   = (level.Contains("WZ")) ? 120 : 300;  // [GeV]
  int   m2l_ngroup = (level.Contains("WZ")) ?   2 :   5;
  
  for (int j=0; j<=njetbin; j++)
    {
      if (!analysis.EqualTo("Top")  &&
	  !analysis.EqualTo("Stop") &&
	  !analysis.EqualTo("WW")   &&
	  j != njetbin) continue;   
         
      TString jetbin = (j < njetbin) ? Form("/%djet", j) : "";

      gSystem->mkdir(outputdir + level + jetbin, kTRUE);

      TString prefix = level + jetbin + "/h_";

      for (int i=firstchannel; i<=lastchannel; i++)
	{
	  TString suffix = "_" + schannel[i];
	  
	  TString title = (i < lastchannel) ? lchannel[i] : "inclusive";

	  plotter.SetTitle(title);


	  // Common histograms
	  //--------------------------------------------------------------------
	  plotter.Draw(prefix + "m2l" + suffix, "m_{" + sll + "}", m2l_ngroup, 0, "GeV", logY, true, m2l_xmin, m2l_xmax);
	  plotter.Draw(prefix + "m2l" + suffix, "m_{" + sll + "}", m2l_ngroup, 0, "GeV", linY, true, m2l_xmin, m2l_xmax);

	  plotter.Draw(prefix + "njet"           + suffix, "number of 30 GeV jets",             -1, 0, "NULL", scale);
	  plotter.Draw(prefix + "nbjet20cmvav2l" + suffix, "number of 20 GeV cmvav2l b-jets",   -1, 0, "NULL", scale);
	  plotter.Draw(prefix + "nbjet30csvv2m"  + suffix, "number of 30 GeV csvv2m b-jets",    -1, 0, "NULL", scale);
	  plotter.Draw(prefix + "dphillmet"      + suffix, "#Delta#phi(" +sll + "," + sm + ")",  5, 2, "rad",  scale);
	  plotter.Draw(prefix + "metPfType1Phi"  + suffix, sm + " #phi",                         5, 2, "rad",  scale);
	  plotter.Draw(prefix + "metPfType1"     + suffix, sm,                                  10, 0, "GeV",  scale, true, 0,  200);
	  plotter.Draw(prefix + "nvtx"           + suffix, "number of vertices",                -1, 0, "NULL", scale, true, 0,   30);
	  plotter.Draw(prefix + "lep1pt"         + suffix, "leading lepton p_{T}",               5, 0, "GeV",  scale, true, 0,  150);
	  plotter.Draw(prefix + "lep2pt"         + suffix, "trailing lepton p_{T}",              5, 0, "GeV",  scale, true, 0,  150);
	  plotter.Draw(prefix + "lep1eta"        + suffix, "leading lepton #eta",               -1, 1, "NULL", scale);
	  plotter.Draw(prefix + "lep2eta"        + suffix, "trailing lepton #eta",              -1, 1, "NULL", scale);
	  plotter.Draw(prefix + "lep1phi"        + suffix, "leading lepton #phi",                5, 2, "rad",  scale);
	  plotter.Draw(prefix + "lep2phi"        + suffix, "trailing lepton #phi",               5, 2, "rad",  scale);
	  plotter.Draw(prefix + "jet1eta"        + suffix, "leading jet #eta",                  -1, 1, "NULL", scale, false);
	  plotter.Draw(prefix + "jet2eta"        + suffix, "trailing jet #eta",                 -1, 1, "NULL", scale, false);
	  plotter.Draw(prefix + "jet1phi"        + suffix, "leading jet #phi",                   5, 2, "rad",  scale, false);
	  plotter.Draw(prefix + "jet2phi"        + suffix, "trailing jet #phi",                  5, 2, "rad",  scale, false);
	  plotter.Draw(prefix + "jet1pt"         + suffix, "leading jet p_{T}",                  5, 0, "GeV",  scale, true, 0,  400);
	  plotter.Draw(prefix + "jet2pt"         + suffix, "trailing jet p_{T}",                 5, 0, "GeV",  scale, true, 0,  400);
	  plotter.Draw(prefix + "dphill"         + suffix, "#Delta#phi(lep1,lep2)",              5, 2, "rad",  scale, false);
	  plotter.Draw(prefix + "detall"         + suffix, "#Delta#eta(lep1,lep2)",              5, 2, "rad",  scale, true, 0, 5);
	  plotter.Draw(prefix + "topReco"        + suffix, "number of tt reco solutions",       -1, 0, "NULL", scale);


	  // ROC
	  //--------------------------------------------------------------------
	  plotter.Roc(prefix + "ht"    + suffix, "H_{T}",         1000, "GeV", 0, 1000);
	  plotter.Roc(prefix + "pt2l"  + suffix, "p_{T}^{ll}",    1000, "GeV", 0, 1000);
	  plotter.Roc(prefix + "mth"   + suffix, "m_{T}^{ll}",    1000, "GeV", 0, 1000);
	  plotter.Roc(prefix + "mtw1"  + suffix, "m_{T}^{W1}",    1000, "GeV", 0, 1000);
	  plotter.Roc(prefix + "mtw2"  + suffix, "m_{T}^{W2}",    1000, "GeV", 0, 1000);
	  plotter.Roc(prefix + "mt2ll" + suffix, "m_{T2}^{ll}",   1000, "GeV", 0, 1000);
	  plotter.Roc(prefix + "m2l"   + suffix, "m_{ll}",        1000, "GeV", 0, 1000);
	  plotter.Roc(prefix + "drll"  + suffix, "#Delta R_{ll}",   50, "rad", 0,    5);


	  if (!allplots) continue;


	  plotter.Draw(prefix + "dyll"         + suffix, "lepton #Delta#eta",                 -1, 3, "NULL", scale);
	  plotter.Draw(prefix + "dphimetjet"   + suffix, "min #Delta#phi(jet," + sm + ")",     5, 2, "rad",  scale);
	  plotter.Draw(prefix + "dphimetptbll" + suffix, "#Delta#phi(llmet," + sm + ")",       5, 2, "rad",  scale);
	  plotter.Draw(prefix + "mllbb"        + suffix, "m_{" + sll + "bb}",                 10, 0, "GeV",  scale, false, 0, 600);
	  plotter.Draw(prefix + "meff"         + suffix, "m_{eff}",                           10, 0, "GeV",  scale, false, 0, 600);
	  plotter.Draw(prefix + "ptbll"        + suffix, "p_{T}^{llmet}",                     10, 0, "GeV",  scale, false, 0, 600);
	  plotter.Draw(prefix + "mt2ll"        + suffix, "M_{T2}(" + sll + ")",               10, 0, "GeV",  scale, false, 0, 600);
	  plotter.Draw(prefix + "mt2bb"        + suffix, "M_{T2}(bb)" ,                       10, 0, "GeV",  scale, false, 0, 600);
	  plotter.Draw(prefix + "mt2lblb"      + suffix, "M_{T2}(" + sl + "b" + sl + "b)",    10, 0, "GeV",  scale, false, 0, 600);
	  plotter.Draw(prefix + "dphijet1met"  + suffix, "#Delta#phi(jet1,E_{T}^{miss})",      5, 2, "rad",  scale, false);
	  plotter.Draw(prefix + "dphijet2met"  + suffix, "#Delta#phi(jet2,E_{T}^{miss})",      5, 2, "rad",  scale, false);
	  plotter.Draw(prefix + "dphijj"       + suffix, "#Delta#phi(jet1,jet2)",              5, 2, "rad",  scale, false);
	  plotter.Draw(prefix + "dphijjmet"    + suffix, "#Delta#phi(jj,E_{T}^{miss})",        5, 2, "rad",  scale, false);
	  plotter.Draw(prefix + "dphilep1jet1" + suffix, "#Delta#phi(lep1,jet1)",              5, 2, "rad",  scale, false);
	  plotter.Draw(prefix + "dphilep1jet2" + suffix, "#Delta#phi(lep1,jet2)",              5, 2, "rad",  scale, false);
	  plotter.Draw(prefix + "dphilep2jet1" + suffix, "#Delta#phi(lep2,jet1)",              5, 2, "rad",  scale, false);
	  plotter.Draw(prefix + "dphilep2jet2" + suffix, "#Delta#phi(lep2,jet2)",              5, 2, "rad",  scale, false);
	  plotter.Draw(prefix + "dphillstar"   + suffix, "#Delta#phi*(lep1,lep2)",             5, 2, "rad",  scale, false);
	  plotter.Draw(prefix + "dphilmet1"    + suffix, "#Delta#phi(lep1,E_{T}^{miss})",      5, 2, "rad",  scale, false);
	  plotter.Draw(prefix + "dphilmet2"    + suffix, "#Delta#phi(lep2,E_{T}^{miss})",      5, 2, "rad",  scale, false);
	  plotter.Draw(prefix + "metTtrkPhi"   + suffix, "track E_{T}^{miss} #phi",            5, 2, "rad",  scale, false);
	  plotter.Draw(prefix + "drll"         + suffix, "#DeltaR(lep1,lep2)",                 5, 1, "NULL", scale, false);
	  plotter.Draw(prefix + "jet1mass"     + suffix, "leading jet mass",                  -1, 0, "GeV",  scale, true, 0,   50);
	  plotter.Draw(prefix + "jet2mass"     + suffix, "trailing jet mass",                 -1, 0, "GeV",  scale, true, 0,   50);
	  plotter.Draw(prefix + "mc"           + suffix, "m_{c}",                             10, 0, "GeV",  scale, true, 0,  400);
	  plotter.Draw(prefix + "metTtrk"      + suffix, "track E_{T}^{miss}",                10, 0, "GeV",  scale, true, 0,  400);
	  plotter.Draw(prefix + "mpmet"        + suffix, "min projected E_{T}^{miss}",        10, 0, "GeV",  logY,  true, 0,  200);
	  plotter.Draw(prefix + "mth"          + suffix, "m_{T}^{H}",                         10, 0, "GeV",  scale, true, 0,  400);
	  plotter.Draw(prefix + "mtw1"         + suffix, "m_{T}^{W,1}",                       10, 0, "GeV",  scale, true, 0,  400);
	  plotter.Draw(prefix + "mtw2"         + suffix, "m_{T}^{W,2}",                       10, 0, "GeV",  scale, true, 0,  400);
	  plotter.Draw(prefix + "ht"           + suffix, "H_{T}",                             20, 0, "GeV",  scale, true, 0, 1500);
	  plotter.Draw(prefix + "htjets"       + suffix, "#sum_{jet} p_{T}",                  20, 0, "GeV",  scale, true, 0, 1500);
	  plotter.Draw(prefix + "htnojets"     + suffix, "p_{T}^{lep1} + p_{T}^{lep2} + MET", 20, 0, "GeV",  scale, true, 0, 1500);
	  plotter.Draw(prefix + "pt2l"         + suffix, "p_{T}^{#font[12]{ll}}",             10, 0, "GeV",  scale, true, 0,  300);
	  plotter.Draw(prefix + "ptww"         + suffix, "p_{T}^{WW}",                        10, 0, "GeV",  scale, true, 0,  600);
	  plotter.Draw(prefix + "sumjpt12"     + suffix, "p_{T}^{jet1} + p_{T}^{jet2}",       10, 0, "GeV",  scale, true, 0,  600);
	  plotter.Draw(prefix + "sumpt12"      + suffix, "p_{T}^{lep1} + p_{T}^{lep2}",       10, 0, "GeV",  scale, true, 0,  600);


	  // WW and MonoH histograms
	  //--------------------------------------------------------------------
	  if (analysis.EqualTo("WW") || analysis.EqualTo("MonoH"))
	    {
	      plotter.Draw(prefix + "fullpmet" + suffix, "projected E_{T}^{miss}",       10, 0, "GeV", scale, false, 0, 100);
	      plotter.Draw(prefix + "trkpmet"  + suffix, "projected track E_{T}^{miss}",  2, 0, "GeV", scale, false, 0, 100);
	      plotter.Draw(prefix + "mllstar"  + suffix, "m2l^{*}",                      10, 0, "GeV", scale, false, 0, 300);
	      plotter.Draw(prefix + "metPuppi"     + suffix, "PUPPI E_{T}^{miss}",                10, 0, "GeV",  scale, true, 0,  400);
	    }

	  if (analysis.EqualTo("MonoH"))
	    {
	      plotter.Draw(prefix + "deltarl1met"    + suffix, "#DeltaR(lep1,E_{T}^{miss})", 2, 1, "NULL", scale, false, 0, 4);
	      plotter.Draw(prefix + "deltarl2met"    + suffix, "#DeltaR(lep2,E_{T}^{miss})", 2, 1, "NULL", scale, false, 0, 4);
	      plotter.Draw(prefix + "deltarllmet"    + suffix, "#DeltaR(ll,E_{T}^{miss})",   2, 1, "NULL", scale, false, 0, 4);
              plotter.Draw(prefix + "deltarjet1met"  + suffix, "#DeltaR(jet1,E_{T}^{miss})", 5, 2, "NULL", scale, false);
              plotter.Draw(prefix + "deltarjet2met"  + suffix, "#DeltaR(jet2,E_{T}^{miss})", 5, 2, "NULL", scale, false);
              plotter.Draw(prefix + "deltarjj"       + suffix, "#DeltaR(jet1,jet2)",         5, 2, "NULL", scale, false);
              plotter.Draw(prefix + "deltarjjmet"    + suffix, "#DeltaR(jj,E_{T}^{miss})",   5, 2, "NULL", scale, false);
              plotter.Draw(prefix + "deltarlep1jet1" + suffix, "#DeltaR(lep1,jet1)",         5, 2, "NULL", scale, false);
              plotter.Draw(prefix + "deltarlep1jet2" + suffix, "#DeltaR(lep1,jet2)",         5, 2, "NULL", scale, false);
              plotter.Draw(prefix + "deltarlep2jet1" + suffix, "#DeltaR(lep2,jet1)",         5, 2, "NULL", scale, false);
              plotter.Draw(prefix + "deltarlep2jet2" + suffix, "#DeltaR(lep2,jet2)",         5, 2, "NULL", scale, false);
	    }


	  // WZ histograms
	  //--------------------------------------------------------------------
	  if (analysis.EqualTo("WZ"))
	    {
	      plotter.Draw(prefix + "m3l"        + suffix, "m_{#font[12]{3l}}",                10, 0, "GeV",  scale, true, 60, 360);
	      plotter.Draw(prefix + "mtw"        + suffix, "W transverse mass",                10, 0, "GeV",  scale, true,  0, 150);
	      plotter.Draw(prefix + "zl1pt"      + suffix, "Z leading lepton p_{T}",           10, 0, "GeV",  scale, true,  0, 150);
	      plotter.Draw(prefix + "zl2pt"      + suffix, "Z trailing lepton p_{T}",          10, 0, "GeV",  scale, true,  0, 150);
	      plotter.Draw(prefix + "wlpt"       + suffix, "W lepton p_{T}",                   10, 0, "GeV",  scale, true,  0, 150);
	      plotter.Draw(prefix + "wlzldeltar" + suffix, "min #DeltaR(W lepton, Z leptons)",  5, 1, "NULL", scale);
	    }
	}
    }


  // Cross section
  //----------------------------------------------------------------------------
  //  root -l eos/cms/store/group/phys_higgs/cmshww/amassiro/HWW12fb_v2/07Jun2016_spring16_mAODv2_12pXfbm1/MCl2loose__hadd__bSFL2pTEff__l2tight/latino_WWTo2L2Nu.root as _file0...
  //  mcWeightPos->GetEntries() - mcWeightNeg->GetEntries()
  //  1.96718e+06
  //
  if (analysis.EqualTo("Control") && level.Contains("WW"))
    {
      printf("\n Cross section\n");
      printf("---------------\n\n");

      for (int i=firstchannel; i<=lastchannel; i++)
	plotter.CrossSection(level,
			     schannel[i],
			     "WW",
			     WW2lnu,
			     "WWTo2L2Nu",            12.1780, 1967180,
			     "GluGluWWTo2L2Nu_MCFM",  0.5905,  481600);
    }


  // Copy index.php in every directory
  //----------------------------------------------------------------------------
  gSystem->Exec("for dir in $(find ./ -type d); do cp -n ../index.php $dir/; done");
  gSystem->Exec("rm -f index.php");
}
Пример #27
0
DispValue *DispValue::_update(DispValue *source, 
			      bool& was_changed, bool& was_initialized)
{
    if (source == this)
    {
	// We're updated from ourselves -- ignore it all.  
	// This happens when a cluster is updated from the values of
	// the clustered dislays.
	if (descendant_changed())
	    was_changed = true;

	return this;
    }

    if (changed)
    {
	// Clear `changed' flag
	changed = false;
	was_changed = true;
    }

    if (source->enabled() != enabled())
    {
	myenabled = source->enabled();
	was_changed = true;

	// We don't set CHANGED to true since enabled/disabled changes
	// are merely a change in the view, not a change in the data.
    }

    if (source->full_name() == full_name() && source->type() == type())
    {
	switch (type())
	{
	case Simple:
	case Text:
	case Pointer:
	    // Atomic values
	    if (_value != source->value())
	    {
		_value = source->value();
		changed = was_changed = true;
	    }
	    return this;

	case Array:
	    // Array.  Check for 1st element, too.
	    if (_have_index_base != source->_have_index_base &&
		(_have_index_base && _index_base != source->_index_base))
		break;

	    // FALL THROUGH
	case Reference:
	case Sequence:
	    // Numbered children.  If size changed, we assume
	    // the whole has been changed.
	    if (nchildren() == source->nchildren())
	    {
		for (int i = 0; i < nchildren(); i++)
		{
		    // Update each child
		    _children[i] = child(i)->update(source->child(i),
						    was_changed,
						    was_initialized);
		}
		return this;
	    }
	    break;

	case List:
	case Struct:
	{
	    // Named children.  Check whether names are the same.
	    bool same_members = (nchildren() == source->nchildren());

	    for (int i = 0; same_members && i < nchildren(); i++)
	    {
		if (child(i)->full_name() != source->child(i)->full_name())
		    same_members = false;
	    }

	    if (same_members)
	    {
		// Update each child
		for (int i = 0; i < nchildren(); i++)
		{
		    _children[i] = child(i)->update(source->child(i),
						    was_changed,
						    was_initialized);
		}
		return this;
	    }

	    // Members have changed.
	    // Be sure to mark only those members that actually have changed
	    // (i.e. don't mark the entire struct and don't mark new members)
	    // We do so by creating a new list of children.  `Old' children
	    // that still are reported get updated; `new' children are added.
	    DispValueArray new_children;
	    DispValueArray processed_children;
	    for (int j = 0; j < source->nchildren(); j++)
	    {
		DispValue *c = 0;
		for (int i = 0; c == 0 && i < nchildren(); i++)
		{
		    bool processed = false;
		    for (int k = 0; k < processed_children.size(); k++)
		    {
			if (child(i) == processed_children[k])
			    processed = true;
		    }
		    if (processed)
			continue;

		    if (child(i)->full_name() == source->child(j)->full_name())
		    {
			c = child(i)->update(source->child(j),
					     was_changed,
					     was_initialized);
			processed_children += child(i);
		    }
		}

		if (c == 0)
		{
		    // Child not found -- use source child instead
		    c = source->child(j)->link();
		}

		new_children += c;
	    }
	    _children = new_children;
	    was_changed = was_initialized = true;
	    return this;
	}

	case UnknownType:
	    assert(0);
	    abort();
	}
    }

    // Type, name or structure have changed -- use SOURCE instead of original
    DispValue *ret = source->link();
    ret->changed = was_changed = was_initialized = true;

    // Copy the basic settings
    ret->myexpanded = expanded();
    ret->dereference(dereferenced());
    ret->set_orientation(orientation());
    ret->set_member_names(member_names());

    // Have new DispValue take over the plotter
    if (ret->plotter() == 0)
    {
	ret->_plotter = plotter();
	_plotter = 0;
    }

    unlink();
    return ret;
}