Log for HW 2 –
Ls – used to list all files in the current directory
Pwd – print working directory
.. – used to go up a directory
Cd – current directory – cd into the directory you want to work in
Cat - cat stands for "catenate." It reads data from files, and outputs their contents. It is the simplest way to display the contents of a file at the command line.
ls –l = Dereference
when showing file information for a symbolic link, show information for the file the link references rather than for the link itself
1. What did it seem like the 'touch' command does?
Touch creates new, empty files to store data into or timestamps into.
2. Why do you think we include that '.' after the 'find' commands?
It is included to search within the current directory
3. Based on the outputs from the four 'find' commands, what purpose do you think the '*' character serves? (Hint: it's called the "wildcard" character in linux jargon)
The star wildcard can represent any characters and is widely used to search. it can be used as the argument for file to return information about every object in the specified directory
4. What did the 'rm' command do, and how do you think 'rm' differs from the 'rmdir' command we saw earlier? Warning: There is no way to undo the 'rm' command!
Rm command removes the directory (deletes it completely)
5. Finally, to test your understanding, why do you think that you should never run the command 'rm *'?
Because we do not want to delete all files! * selects all files
1. What do the '>' and '>>' operators do? How are they similar? How are they different?
To redirect standard output to a file, the ">" character is used.
using ">>" new results will be appended to the file.
2. What is one potential danger of using the '>' operator?
Each time the command > is repeated, file_list.txt is overwritten (from the beginning) with the output of the command ls.
3. What do you expect to see if you run:
· ls -l > log.txt = permissions , user created, users, date accessed
· cat log.txt = data inside the file
more - More is a filter for paging through text one screenful at a time.
Log for HW 3 –
What do you think the difference between ARG and $ARG is?
Arg can be an argument/option whereas $arg is a variable
Tip :Ctrl + l – scroll down for clean window
Github –
tick allow ssh access
When asked for passphrase for /home/usr press enter
You can set a passphrase for id_rsa
Ssh agent –c (ssh agent –s is for bash ; we use tcsh)
Putty has no clipboard – so instead use cat ~/.ssh/id_rsa.pub and copy it and remove all the spaces after every line so that its one big key instead of chunks. Make sure you remove spaces in github public key when adding on github.com
Simple first time steps
git init
git add filname.extension
git commit -a -m "first commit"
git remote set-url origin git@github.com:<your_github_username>/<your_repository>.git
git push -u origin master
git pull origin master - do it before you make a change from your computer on a shared project to not get the ‘back in time’ error
every other time
git init
git add filname.extension
git commit -a -m "commit name"
git pull origin master
git push -u origin master
to check set-urls
git remote –v (we use SSH)
Github working fine. No problems in setting up or accessing it.
Log for HW 4
#include <iostream>
using namespace std;
int main() {
cout << "hello world" << end;
int i=2;
cout << "i = " <<i<<endl;
double a=3.3;
cout << "a = " <<a<<endl;
int j = a*i;
cout << "a*i = "<<j<<endl;
return 0;
}
Note any interesting results. [ compiler makes int to double!! ]
What do the ++ and -– operations do?
++ increments the variable by 1
-- decrements the variable by 1
Loops and Other variable types should be pretty straightforward.
(just remember when you get ‘)’ expected before ‘}’errors your conditions in the loop must be separated by a semi colon! Not a comma!
Debugging : seems pretty complex : isn’t. Watch I and info locals are your go to debugging commands.
Steps
gdb
'-g' flag ( g++ -g bug.cpp)
gdb ( gdb)
file a.out )
Now, list out some of the source code:
list
You can specify a line to center the list around.
list 12
break 1 ( or b 1 for short ) to tell gdb to pause at the first line of the program.
enter run ( r )
You can look at all the local variables with the info locals command.
info locals
You can also just run the next line
step
watch i ( wa i )
continue ( c )
Log for HW 5
If else statements are pretty useful just make sure you use the right number of opening and closing brackets.
Simple guide to pointers
&i = The memory address of i
int* p = &I (int* used to declare type of data expected in the pointed location)
p ‘points at’ the memory location referenced by address is &i
The * operator tells the program to open the memory location ‘pointed at’ by p and retrieve the data inside
The data stored at memory address p is *p
you can declare a pointer without having to point to an already used memory address. In c++, this can be accomplished using the ‘new’ construct.
Program 1 has two different variables stored in different locations. And only j changes when i changes but I doesn’t change when j changes. But for the second one, it’s the same data in the same location!
C++ topics log
G++; g++ -dumpspecs; variables; Boolean; for, while, do while loops, GDB, logic (if else statements), pointers,
Log for HW 6 –
The better random number generator using SRand() and feeding these numbers into an array
#include <iostream>
#include <stdio.h>
#include <stdlib.h>
#include <time.h>
using namespace std;
double makeRand(double fMin, double fMax)
{
double f = (double)rand() / RAND_MAX;
return fMin + f * (fMax - fMin);
}
int main() {
srand (time(NULL));
double num[100];
int i;
for(i=0; i<100;i++)
{
num[i] = makeRand(0.0,1.0);
}
Log for Hw 7 –
- When writing C++ code in Root and including header files you include the local root header files in “ “ ex “TMath.h” and C++ libraries <> example <iostream>
- Also for executing .C files in root you also need to have the file name the same as your method name. For example is you have, void graph() { method body} your file name should be graph.C; not following this will give you an interpreter error
- Whole numbers are written with a dot next to them so 10 would be “10.” And exponents are raised by having star twice so (10-8 would be 10.**(-8))
- Important options for plot – Draw(); SetTitle(); syntax Plot (“equation to plot”, lowest x value on axis, highest x value on axis)
- Important options for Histo1 – Draw(); SetMarkerStyle(); FillRandom() *** ; syntax would be Histo1 (“Mean table title”,”histogram title”,number of bins, smallest number, biggest number);
- Great thing about histograms – Fitting – You can have the data fit to any distribution using
histo1 -> Fit();
Log for HW 8 –
- Graphs introduced – Can have superimposed graphs and error bars
- Trees – Kinda hard to understand but a good look should make it a tad easier
Log for HW 9 –
Making cuts – If statements inside the events for loop to filter out unwanted events
Simple tips for the macro to compare; if your graph is empty – the macro might be fine but you might have the wrong addChain statement in the header file! Remember to keep changing the header, the actual .C file and the compare micro