Almost everything in this journal will be coding related, because my physics notes are in my notebook. No need to write those down twice.
Also, look at programs on Git Hub and elsewhere for example codes: almost all have notes.
9/26/2016
This first entry will be a large bulk entry because I haven't had a chance to make a post up until now: transferring files from cluster, basic code structures, basic commands and their structures, and Git Hub commands.
10/2/2016
General edits and extensions to sections on C++ and shell code structures.
10/10/2016
Added info on using ROOT.
10/23/2016
Added info on creating canvases and plots. See IanFogartyFlorang_HW7_Physics2.C for more notes on these topics. Added SCP for ROOT.
To transfer files to and from the cluster:
FROM CLUSTER: scp hon-fogarty@hepcms.umd.edu:/home/hon-fogarty/PhysHonr268n/filename.ext /Users/iff700/Documents/College\ Stuff/HONR268N
TO CLUSTER: scp /Users/iff700/Documents/College\ Stuff/HONR268N/filename.ext hon-fogarty@hepcms.umd.edu:/home/hon-fogarty/PhysHonr268n
for homework:
scp hon-fogarty@hepcms.umd.edu:/home/hon-fogarty/PhysHonr268n/Homework/filename.ext /Users/iff700/Documents/College\ Stuff/HONR268N/Homework
for ROOT programs:
scp hon-fogarty@hepcms.umd.edu:/home/hon-fogarty/PhysHonr268n/ROOT/CMSSW_5_3_30/testRoot/filename.ext /Users/iff700/Documents/College\ Stuff/HONR268N/Homework
Git Hub Pushing:
To add new files to GitHub use following commands once in correct directory:
git add filename.ext
git commit -a -m "Description of Changes"
git push -u origin master (after 1st use in session can just use "git push")
To update added files:
git commit -a -m "Description of Changes"
git push -u origin master (again, can use "git push" after 1st use)
Using ROOT:
Every time, start by doing the following:
cd to CMSSW_5_3_30
cmsenv
cd to testRoot subdirectory
root -nw
Use .q to exit
Script Structure:
Shell Script:
Name it *.tcsh
Structure:
#!/bin/tcsh
Body of Code
Using # before a line makes it read only. The code doesn't take it into consideration. Good for making notes.
C++ Script:
Name it *.cpp
Structure:
#include <iostream>
using namespace std;
int main() {
Body of Code
return 0;
}
Using // before a line makes it read only. The code doesn't take it into consideration. Good for making notes.
Same goes for enclosing text between /* and */
Structure of Specific C++ Commands and Their Purpose:
for loop:
Basic Structure -- for(variable=starting value, test variable, edit variable) {statement}
Purpose -- Whenever the test is true, the statement will be run. This loop just repeats the statement a number of times as the variable changes from its starting value until the test isn't true.
Example -- for(int x=1, x<=7, x++) {cout<<"Hello!<<endl;}
This example will say the text Hello! followed by and end line every time the loop proves true. x starts at one, the test proves true, it outputs "Hello!", then x is increased by one and tested again. This repeats until x is 8 ands the test proves false.
Important Things to Know for Root
Some Command Structures/Uses
Making Canvases and Plots:
Use structure:
TCanvas *call_name=new TCanvas("call_name","title",x width in pixels, y width in pixels) (Can also specify pixel ranges)
You can then also divide up your canvas into multiple "pads." Use:
call_name->Divide(columns,rows)
For Ex. c1->Divide(2,3) would divide canvas c1 up into 6 parts, in two columns and three rows.
You then use this command to specify what pad you want coming commands to apply to:
call_name->cd(plot number)
Note, this counts pads from top to bottom, left to right. Using the same canvas/pad example above, c1->cd(5) would refer to the 1st pad on the 3rd row.
This is useful in situations where you want multiple things listed on the same window, for example multiple side-by-side graphs.
See HW7 Physics 2 for a perfect example.
Making a Graph with Error Bars
See Homework 8 part 5. File has example and important notes.