This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <iostream> | |
class Foo { | |
public: | |
class Bar { | |
public: | |
Bar(Foo* owner) : owner(owner) {} | |
int getter() { return owner->a; } | |
private: | |
Foo* const owner; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
ifndef ROOTSYS | |
$(error ROOTSYS is not defined) | |
endif | |
all: minuit_example | |
minuit_example: | |
g++ -o minuit_example minuit_example.cpp `root-config --libs --cflags` -lMinuit | |
clean: |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
'''An example PyROOT analysis which applies several different NHIT cuts, | |
calculates the fraction of events failing, and produces a plot. | |
''' | |
import sys | |
import array | |
from rat import ROOT | |
def fast_dsreader(filename): |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** Get a value from a TNtuple by event id and name */ | |
float get_ntuple_entry(TNtuple* nt, int i, std::string field) { | |
float v; | |
nt->SetBranchAddress(field.c_str(), &v); | |
nt->GetEvent(i); | |
nt->ResetBranchAddresses(); | |
return v; | |
} | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
'''Example of labeling only some plots in a matplotlib legend. | |
Tested with matplotlib==1.0.1 | |
''' | |
from matplotlib import pyplot as plt | |
plt.figure(1, facecolor='white') | |
plt.plot([1,2,3,4], [1,2,3,4], label='foo') | |
plt.plot([1,2,3,4], [2,4,6,8]) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <stdio.h> | |
class foo { | |
public: | |
int thinger() {} | |
}; | |
int main(int argc, char* argv[]) { | |
int i; | |
foo f; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
'''Example of a custom ReST directive in Python docutils''' | |
import docutils.core | |
from docutils.nodes import TextElement, Inline | |
from docutils.parsers.rst import Directive, directives | |
from docutils.writers.html4css1 import Writer, HTMLTranslator | |
class foo(Inline, TextElement): | |
'''This node class is a no-op -- just a fun way to define some parameters. | |
There are lots of base classes to choose from in `docutils.nodes`. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <iostream> | |
#include <thread> | |
/* g++ -std=c++0x -o thread-cpp11 thread-cpp11.cxx -lpthread */ | |
class Bar { | |
public: | |
Bar() : i(0) {} | |
int i; | |
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <iostream> | |
#include <pthread.h> | |
/** Member function pointers given function name */ | |
// class Launcher exists as a container of an instance and an argument. | |
// Using templates allows us to use the Launcher for a member of any class | |
template <class T> | |
class Launcher { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <iostream> | |
#include <pthread.h> | |
/** Calling a member function using a mysterious superclass */ | |
#include <stdio.h> | |
class Super; | |
typedef void* (Super::*pSuperMF)(void*); |