R schoolStamps
From MariachiWiki
Jason Immerman wrote a script (download here) that allows a vast amount of manipulation of the timestamps data including: averaging, plotting locally as well as globally, getting operational windows, calculating timestamps rates, finding accidental coincidence rates for overlaps of operational rates, plotting overlaps of operational windows, and finally verifying data.
This page contains only brief descriptions. In addition, see note at bottom.
Contents |
The Driver
To run the script, after sourcing the file in R:
source("schoolStamps.R")
one must run the driver that reads in the timestamps data and stores it in a list called main. Eventually all data will be stored in this list in separate lists. To see the different lists stored within main at any point type:
names(main)
To call the driver:
schoolStamps()
You can now move onto a function of your choice. At any point when there is a reference to school name, this corresponds to the exact name of the school that appears timestamps and counts file names (which should be identical).
Averaging
To call this:
avg("*school name*",interval)
where interval is a number in minutes for which the timestamps will be averaged over.
Global Plots
To call this:
globalPlot("*school name*",interval)
where interval is the number in seconds for which no time stamp line appears signals a time of a non-operational detector. The default is one year in seconds (thus producing no such windows). See Operational Time Windows for more information. The windows are outlined by a green vertical line signaling the start of an operational window and a red vertical line signaling the end of an operational window. The plots show only averaged counts.
Local Plots
To call this:
localPlot("*school name*","first","last",interval)
Here interval is the same as that described in Operational Time Windows. Also, first and last are the times for the beginning and end of the viewed plot in GMT (in quotes). The plots show both average counts and raw data in the same window.
Operational Time Windows
Used primarily by Calculate Timestamps Rates function.
To call this:
getOperational("*school name*", interval)
Here interval, as described in Global Plots, is the time for which a time stamp line does not occur (and thus a coincidence does not occur on the detector site). This function returns a data matrix containing the beginning and ending of each operational window in GMT.
Calculate Timestamps Rates
To call this:
calcRates("*school name*", interval)
Here interval refers to the same that is defined in Operational Time Windows. This appends a list "windows" to main that contains a data matrix of the beginning, ending and rate of each operational window.
Accidental Coincidences Between Arrays
To call this:
accCoin(w,interval)
Here w is the coincidence window, predefined as 1e-4 seconds. The interval is the same that is described in Operational Time Windows. This function is used to determine the accidental coincidence rate between schools given their windows of operation and the counts rates therein. It used the formula rate of accidentals = 2*r1*r2*w, which has been proven in the numerical simulation of two detectors (found here). The function sets up an output file, accCoin_output.txt, in the working directory that contains the accidental coincidence rate between each pair of schools, the total number of accidental coincidences based on this rate and the total number of accidental coincidences between any array.
Plotting Operational Time Window Overlaps
To call this:
plotOverlaps("*first school name*","*second school name*")
This will globally plot overlaps between two arrays. The plot will contain three distinct lines: one that represents timestamps of one school (in blue) the middle that contains a green point for the start of an operational window and a red point for the end of an operational window, and finally the bottom line representing timestamps of another school (in blue). The interval that defines windows of operational arrays is based on the last call to calcRates().
Verifying Data
To call this:
verifyData("*school name*")
This verifies the data in two ways: builds a histogram between successive timestamps -- should be exponential decay representing the fact that this time difference between successive timestamps is mostly very small -- and building a histogram of the difference between timestamps and counts data for c4 and c5. This is explained in more detail in the ROOT script verify data that has the same function, found here.
Note: This script was made for a mac computer, as well as the file paths being customized for my computer. Three types of changes must be made in the source code: graphical interface, file paths, and file names.
The graphical interface for mac is quartz. The most common windows or linux type is x11. Thus wherever quartz() appears in the code, it must be changed to x11(), or whatever other graphical interface will work for you. (Lines 154, 165, 198, 490, 593)
The file paths are specific for the computer on which the code was written on and must be changed. These paths correspond to the folder containing the timestamps and counts data. The timestamps folder path appears in lines 31, 38 and the counts folder path appears in line 607.
Lastly, the file names for the counts and timestamps files must be changed (either in the code or on the computer). The easiest way to correct this is to have each counts file be named *school*_counts.txt and each timestamps file named *school*-timestamps.txt. However, to change this in the source code these appear in lines 35 ("-timestamps") and 534 ("_counts.txt").
