C++ and STL

C++ in a nutshell

#include <iostream>

int main() {

    /* Variables */
    int integer_variable;
    double read_variable;
    bool boolean_variable;

    /* Operations */
    a = b + c - d * e / f;
    i = j % k;
    a += b;
    a -= b;
    a *= b;
    a /= b;
    i %= j;

    /* Conditions */
    if (a == b and c != d) { /* ... */ }
    elseif (a >= b and c <= d) { /* ... */ }
    else { /* ... */ }

    /* Loops */
    while (condition == true) { /* ... */ }

    for (unsigned int i = 0; i < 10; ++i) { /* ... */ }

    do {
        /* ... */
    } while (condition == true);

    /* Displaying text */
    std::cout << "Hello world!" << std::endl;

    return 0;
}

STL in a nutshell

#include <vector>
#include "TH1D.h"

{

    /*  Create an empty vector of TH1Ds */
    std::vector< TH1D* > th1ds;

    /*  Add a TH1D to the vector */
    th1ds.push_back(new TH1D("name", "Title", 1000, 0., 0.));

    /*  Access the TH1D */
    th1ds.at(0)->Fill(value);

    /*  Or */
    TH1D* histogram = new TH1D("hist_gaus", "Gaussian distribution;X;Number of events", 1000, -10., 10.);
    th1ds.push_back(histogram);
    histogram->Fill(value);

    /*  Go over the elements of a vector */
    for (unsigned int i = 0; i < th1ds.size(); ++i) {
        th1ds.at(i)->Write();
    }
}