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
/** | |
* Creating a list of keys from an STL map. | |
* | |
* Build: g++ -o keys keys.cpp | |
* Run: ./keys | |
*/ | |
#include <iostream> | |
#include <map> | |
#include <string> |
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
'''Plot PMT hit time residuals from the RAT DS. | |
Usage: | |
$ python time_residuals.py "filenames_*.root" | |
With one filename or wildcards (use quotes when using wildcards). | |
The histogram opens in an interactive ROOT window for editing. | |
''' |
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
/** | |
* Plot ES scattering angle for 8B solar neutrinos vs. recoil energy, | |
* weighted by the neutrino spectrum. | |
* | |
* This uses the 8B spectrum and ES cross section code in RAT. | |
* | |
* Build: | |
* | |
* g++ -g -o es es.cpp -L$RATROOT/lib -I$RATROOT/include \ | |
* -lrat_Linux `root-config --libs --cflags` \ |
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
// Draw overlaid histograms from a RAT ntuple (for example). | |
// | |
// Usage: | |
// $ root -l -x 'overlay.C("filename1.root", "filename2.root")' | |
// | |
// The trick is that histograms are associated with a TDirectory | |
// upon creation, which is most likely the open file. When the | |
// directory changes when a new file is opened, the pointer to | |
// the histogram is invalidated. TH1::SetDirectory is used to | |
// detach a histogram from a file. |
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
'''A minimal example of how Orca might interact with the CouchDB database | |
to load settings from the DB at startup and write settings to the DB only | |
when they change. | |
Because Orca is the only *producer* of the database data, it can keep track | |
internally of whether the detector configuration has changed. | |
NO: Checking in-memory settings against values in the DB | |
for fec in fecs: |
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
#!/usr/bin/env python | |
'''Report the SMART status of hard disks using a log file.''' | |
import argparse | |
import subprocess | |
import sys | |
# Nagios status codes | |
OK, WARNING, CRITICAL, UNKNOWN = range(4) |
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 script for drawing MCPhoton information from RAT-PAC ROOT files. | |
* | |
* Usage: | |
* | |
* root[0] .L mcphoton.cpp+ | |
* root[1] plotMCData("myfile.root"); | |
* | |
* A. Mastbaum <mastbaum@hep.upenn.edu>, June 2015 | |
*/ |
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
from datetime import datetime | |
import pytz # Probably need to install this one on your system | |
import dateutil.parser | |
# An example timestamp string | |
timestamp = "2014-12-12T08:51:06.082327-05:00" | |
# Convert the string to a datetime object | |
timestamp_obj = dateutil.parser.parse(timestamp) |
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<vector> | |
/** There are two ways to access the ith element of an STL vector, the usual | |
* v[i] syntax or using v.at(i). | |
* | |
* The former doesn't check array boundaries, so something like v[v.size()+1] | |
* works and gives you whatever happens to be sitting in that memory location. | |
* | |
* v.at() has the same purpose, but actually throws an exception |
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
/** A simple example of an invalid pointer dereference. | |
* | |
* a is not a valid pointer until initialized, so dereferencing it (here, | |
* setting it to 37) is bad news. | |
* | |
* Note that C++ doesn't necessarily initialize pointers to NULL, so it is | |
* possible that this will "work" and not cause a segmentation fault. This | |
* could be really bad, trampling some other memory. We're lucky to get a | |
* segfault. | |
*/ |
OlderNewer