2/2/16
12/17/15
Things I learned coding a monte carlo in root for the final:
#include <TRandom.h> is he library in root for random numbers
#Include <TRandom.h> is the header for random numbers in root
for every variable type, there is a special t version, like int becomes Float_t. I don't see the need
to create a canvas it looks like //TCanvas *c1 = new TCanvas("c1","Tracker Simulation",200,10,700,500);
creating a histogram looks like //histo1 = new TH1F("histo1","Measured PTs",100,momentum-range,momentum+range);
to fill this histogram you do //histol->Fill(<your data>);
instead of using = to set a value, root lets you use -> instead, I don't see the point of this
random numbers can be generated in root with the function ran.dist(<parameters>) where dist determines the type of distribution to use
11/17/15
To run a program in root, you have to open root, load that script, and then execute it
Root is launched with $ root
To load a program:
do .L <filename> if you are inside root
$ root -l <filename> works in the terminal
to execute a program, try .x <filename.C> within root
10/26/15
how to initialize root:
I configured ~/HONRPHYS/CMSSW_5_3_30 to work with root, also make sure X11 is working when you do this
cd to that CMSSW_5_3_30 directory
type $ cmsenv
cd to the testRoot subdirectory in CMSSW_5_3_30
start root with $ root -nw
end root with .quit
arrays are essentially matrices that can store data
to make a nxnxn... array, you use something like "int LL[2][3] = {1,2,3,4,5,6};"
to index an element, each row, column, etc numbering starts at 0 and goes up from there
comments can be put in like "/* words words */" or, for just one line, "// words words"
remember to make variable names make sense
the following creates, opens, writes to, then closes and saves a text file:
ofstream myfile;
myfile.open("example.txt");
myfile<<"write some junk.";
myfile.close();
if you have a function in one program you want to run in another, you can run it by doing the following:
at the top of your program, you have to include the other program with "#include "codefilename.cpp""
then in main you can just call any function from codefilename.cpp as though it were in your program
to make some pretty good pseudo-random numbers, you can do it by:
including stdlib.h which has the srand and rand functions, and time.h which can get you the time
then you have to do a "srand(time(NULL));"
and a "rand()%n+k" which will give you a number between k and n+k
also if you have a file with values delineated with spaces, you can load them into variables like:
so say your file is called "filename.txt" and it has text like "a b c"
you include "fstream" then you type:
"ifstream myfile;"
myfile.open("filename.txt");
myfile>>varA>>varB>>varC>>;
myfile.close();
now varA == a, varB ==b, and so on
10/12/15
debug solution: to run a tcsh script (note a tcsh is not a cpp file) you type $ tcsh ./filename.tcsh
learned about pointers and variables from the tutorial
each variable has an address in memory where the value of the variable is stored
to read the address of a variable, we put & in front of the variable
to declare a pointer, we use something like "int* p = &i" where p then stores the pointer of an int (as declared with int*) and &i means the address of i
we can access the data stored at the address referenced in a pointer p by using the *, as in *p, which would give the value of the original int i
when p points to i, changing i changes *p, and changing *p changes i
you can create a value at a completely new address using new: ex "int* p = new int(5);"
10/5/15
managed to successfully code, compile, execute, and commit all the tutorial programs given in HW 4 (including the one about factoring all numbers 1-100 and calculating factorials)
all these programs can be found on the server at /home/neves/HONRPHYS/ (note that as of this writing neither of my programs to test my ability by making a blackjack game are working well, sorry)
notes on bugs in source code:
line 5 of the program about variables says "end" when it should say "endl"
the last cout command in the program "some operations with numbers" is missing a quote
some general things I need to remember:
the syntax for a for loop is like: for(int i=1; i<10; i++) //notice the semicolons are not commas
cout is a great tool for displaying things to the screen, ex: "cout << "a = " << a << endl;" though I need to also #include <iostream> at the beginning
9/30/15
now able to push changes to git repository from cluster, commands to add a new file are:
git add <filename>
//adds file to index
git commit -a -m "some commit comment"
//records changes to the repository
git push -u origin master
//updates remote refs along with associated objects
to update a file I just need to do the last two commands
realized I have so much to learn on how to use git
also able to compile and run code in c++ on cluster (though I am wondering how to change the name of the compiled code from "a.out")
9/22/15
connected github account to cluster account, involved something with ssh keys
debugged: learned from classmate that the symbol ' is not the same as `
helped classmates learn about permissions and chmod
9/21/15
learned how to make a .tcsh in emacs and edit/execute it
tcsh is a c shell, execute with "tcsh <directory/filename> <argument>"
variables have a $ in front of them
chmod is the command to change permissions on a file
piping (character "|") is used to link the output of a command on the left to the input of a command on the right
condor lets you run a program while still using your console, a tutorial can be found here http://research.cs.wisc.edu/htcondor/manual/quickstart.html
created github account, username: paulneves77
connected github account to cluster account, did something with ssh private keys
Debugged: learned from classmate that the symbol ' is not the same as `
9/17/15
Created logbook page under "268N-2015" in class.
Still need to figure out proper formatting on this site
Before 9/17/15
Refresher on various linux commands:
ls -l -h
cd
pwd
echo
find
mkdir
rm
~, ..
Linux programs:
cat to read files
emacs -nw "file_name.extension" to create/edit text files
ctrl+x ctrl+c y to save and exit
more commands at http://www.gnu.org/software/emacs/manual/html_mono/emacs.html