HONR269L
5/7/19 Final Res Plot
Lena was able to get a res plot in root. The following is that resolution plot
5/4/19 Problems with Geant4
I was doing some runs to get resolution values last night and I'm not sure what happened but every time I do a run today it cancels the run and says "Aborting Execution". Also all of my command history is cleared and I can't make a new build.
The only idea as to why this might have happened is possibly I overwrote the .cc files when I ran root. I can't clearly remember running the source cvmfs/sft.cern.ch/lcg/views/LCG_95/x86_64-slc6-gcc62-opt/setup.csh command before running root (although I almost always do). I was so close to getting the final resolution plots and unfortunately this happened. I'm going to try to fix this, but it's not looking good. Fortunately, Lena has basically exactly the same build and she's also working on the resolution plots so we should end up with a final graph even if I can't get it to work on my PC.
The following is the error I get whenever I try to run anything on my current build.
The following is the error I get when I try to make a new build.
5/2/19 Making Res Plots Manually
Today, I spent a considerable amount of time conducting runs manually to try to get resolution plot. I am doing 100 pi+ for energies 10, 20, 30 ... 90, 100 GeV. I got a little bit over half of these energies completed and these are the following rms/mean values I got for the runs I did.
100 GeV = 13.26/71.98
80 GeV = 11.48/58.13
60 GeV = 7.366/44.82
50 GeV = 7.963/37.11
40 GeV = 5.765/30.61
30 GeV = 4.366/24.35
So far it does not seem like there is a trend towards a 1/x graph, but when Lena did her res graph it seemed like the drop happened very early around 20-30 GeV so there is still hope.
4/27/19 - Lena's working on Script
It turns out Lena's working on a script that should make my job of testing resolution values for different correction values much easier. Since, we have two weeks to finish this research I decided to wait for her to finish the script up before working on my analysis of "dead material correction values" affect on different resolutions.
4/26/19 - Team Meeting
I met with my team today. We discussed our current progress and prospect for future research. Dr. Eno was happy with our progress and encouraged us to test more resolution graphs. I volunteered to test multiple resolution graphs against different "dead material correction values". I'm not exactly sure how to do this in root, but I can definitely get the data and input it into excel. Also, Lena and I have set up a place to work on the final paper due for this class which discusses our research thus far. In general, the actual research has slowed down, and now we're working on summarizing what we've done over the past few months.
4/23/19 - Team Got First Resolution Graph!
While I was trying to better understand how to write code in root, Lena was able to get our first resolution plot. It is shown below:
The x-axis represents energy in GeV and the y - axis is the resolution (rms/mean).
4/22/19 - Continued learning about TTrees
Basically there are 5 steps when creating a TTree:
1. First, you need to create TFile Object. You have the option of creating a new file for writing or updating an existed file for writing/reading.
2. Create a TTree Object.
3. Add a Branch using TTree::Branch().
4. Fill the Tree with Data
5. Finally write the tree and you have your finished product.
4/20/19 - Becoming more familiar with root
This week is mostly going to be focused on becoming more comfortable with the root code. Before now we've mostly needed to just adjust a few things in Marco's code. However, we're starting to have to write more complex code and I feel like I'm starting to fall behind. The best resource I've found for learning root more completely is root.cern.ch. For example, I used this tutorial to better understand how to write a tree in root:
4/16/19 - Implementing Lena's Code
Today, Lena posted a block of code on our team's slack that creates a new Tree which provides the energy based on the scaling factor. The code adjusted the CreateTree.cc class in ~/cepc_calotiming/src
After making the changes and remaking I simply ran 10 10 GeV pi+ and I ended up with this histogram:
As you can see the average was only about 6.894 GeV which many indicate that there is an issue with the size of my active HCAL layers or my Dead Material Correction Value.
4/13/19 - Getting a more accurate value for Dead Material Correction
Dr. Eno suggested I do runs at a few different energies to determine whether or not the Dead Material Correction Value varies. In theory, it should not change. However, I found that it fluctuated a bit. There was no obvious trend seen in the data so I chalked this up to uncertainty and randomness. Here are the scaling factors for the extra runs I ran along with the average of all of them.
We will be using the average of all runs as the scaling factor for all future runs.
4/12/19 - Finding the Dead Material Correction Value
Dr. Eno informed us that we needed to find the "dead material correction value". This value should be used to find the total energy deposited in the hcal using just the active layers as detectors. The way to retrieve this value is to take the (Edep in Passive Layers / Edep in Active Layers). I ran 100 runs of 100 GeV and managed to get a correction value of about 96.46.
This value is able to be used in a formula to find the total energy deposited in the calorimeter. The formula is as follows: ECAL_Energy + HCAL_ACTIVE_ENERGY*Scaling Factor.
4/9/19 - Getting Visualization for Current Calorimeter Config
As we add more to the calorimeter it seems to take exponentially more time to get visuals to load. For example, at the beginning, it took a few seconds to get visualization up and running. However, it took about 20 mins to load the graphics for the calorimeter as it is right now. Here is the a screenshot of the visualization received:
4/8/19 - Increased Width of Services Section
In the slack, one of my team members showed this image indicating how to increase the simulated wiring of the calorimeter. This is important because in real life showers can occur in these sections and we want to model that occurrence as accurately as possible.
4/7/19 - Full Reset of Code
Nobody seemed to know the source of the "segmentation fault" error. It was suggested that I remove all of the crystal calorimeter libraries and re-download them. This took a while because I had to re-edit everything I have changed in the past few weeks. However, once I did it, the code worked properly. I continued to change the # of crystals, but after altering the # of crystals to 250,000 I ran into the same "segmentation fault" issue. It seems that if you set the number of crystals too high the code crashes. I adjusted the # of crystals to 50,000 and I'm still kicking myself over wasting so much time on a bug that could of easily been prevented if I was more modest with my preset values.
4/6/19 - Bugs in Code
Today was a very rough day in terms of productivity. I started the day trying to C-make a new build but ran into this issue:
After a lot of trial and error I traced the bug back to running this command before cmake-ing: "source /cvmfs/sft.cern.ch/lcg/contrib/gcc/4.8.4/x86_64-slc6/setup.csh". I usually use this command to access root in the same session as a ./CEPC_CaloTiming run.
After finding the solution to this bug I ran into another issue while actually executing a run. This was the error message:
I spent hours trying to figure out what the issue was with this piece of code and still can't find the source of the error. I put the error message in our team's slack to see if anybody knows how to fix this error. Hopefully, I'll be able to come to a fix in the near future.
4/4/19 - Increasing Size of ECAL
In order to increase the size of the ECAL, it will not help to simply scale the size of the crystals. Instead, crystals need to be added to the calorimeter to make the width of the ECAL larger. The variable to change the number of crystals is called const int NECAL_CRYST as shown below.
As seen, I increased the number of crystals to 50000 from 2500.
I continued to play around with the number of crystals.
4/1/19 - Histogram with several runs
Just to confirm the improvement that was made and find a more accurate representation of our improvement I ran 25 runs of pi+ at 10 GeV and got a histogram that fits nicely with the one previous run executed before.
Throughout these runs the average energy yield was about 81% which is a significant improvement.
3/30/19 - Run with improved Calorimeter size
Now, I wanted to see the impact had on the visualization and total energy distribution. I again ran a pi+ at 10 GeV and this is what I ended up for the visualization:
As you can see, much more of the energy is contained as opposed to the previous simulation. While the visualization gave us an idea of how much more energy we'd be getting I wanted more definitive data so I looked at the depositedEnergyTotal histogram in root for this particular run.
We managed to get a yield of about 81.9%. This is a HUGE improvement. Dr. Eno suggests we make the ecal larger as well by adding more layers of the crystals.
3/30/19 - Increasing size to increase energy yield
Today, I wanted to figure out how to increase the size of the hadron calorimeter (the red and gray box) to achieve a higher total energy yield.
I figured out how to change the width of the hadron calorimeter without having to re-cmake everything. I simply went into my build file and altered the template.cfg file.
I increased the width of the hcal to 5 meters. This may seem a lot but it's just a simulation, and fortunately, simulated calorimeters do not cost money (credit to Dr. Eno for that revelation).
3/29/19 - Finding source of low energy yield
As seen in the depositedEnergyTotal histogram, the enegy yield we were receiving was very low. I was running a 10 GeV pi+ and getting values of around 100 MeV. To see why this problem was occurring I decided to run a visualization. I sent one 10 GeV pi+ particle through the graphics software and ended up with this:
Obviously, it is now easy to see that the secondary particles are leaving the HCAL before they have time to interact with the material. Dr. Jabeen noticed this and suggested making the calorimeter larger.
3/26/19 - Fixed Root Problem!
When I applied the changes Dr. Eno provided over break and re-cmaked, I forgot to add a file called gps.mac to my build directory. There is a lot to remember when cmake-ing on this software so I will put the directions below.
1. Make a new build directory.
2. Obviously, I have to run the cmake and make commands. There are a few error messages that pop up but nothing that prevents me from running what I intend to run.
3. Copy vis.mac, template.cfg, and gps.mac from the CEPC_CaloTiming project in github to my build directory.
4. Make a .mac file that specifies the settings I want for a particular run (much like the code shown in 3/24/19)
When I did all of these steps correctly, completed a run, and checked root I was able to see data in all the preset histograms. Here are a couple examples:
3/25/19 - Having Trouble getting Data to Root
For some reason, when I open up root and look at the preset histograms there is no data to show. There are tons of places for histograms but all are blank. This is troubling because, in order to get any actual useful data, I will need to use these histograms.
3/24/19 - Fixes to Code
Over break, Dr. Eno sent us some fixes to the code of the crystal calorimeter that should allow us to complete runs without graphics. Today, I worked on implementing those fixes into my personal code. I was finally able to get a run with graphics on my PC along with a run without graphics.
Here is the run with graphics (Note: in order to run the code with graphics I needed to ./CEPC_calotiming template.cfg to get the UI to pop up. Then in the session I ran /control/execute file.mac)
The above examples were run with a file I named run1.mac which is below:
This code is very simple. It simply means that I am running 1 positively charged pion at 10 GeV. Note: Because of the code we're using, we now have to replace the gun command with gps which was previously used in mac files.
3/15/19 - Meeting w/ Dr. Eno
This week in the meeting with Dr. Eno we attempted to get runs working on the crystal calorimeter without graphics(shown below, 3/12/19). We ran into some issues, however, and were not able to get runs without graphics.
3/12/19
Dr. Eno managed to get the code working on the cluster. She provided us with instructions on how to get it working properly on the system, however, I personally have not had time to work on it due to an upcoming exam.
When I am able to set aside time to work on it, the calorimeter should look something like this:
3/11/19 - Attempting to Get Code working on PC
All of us on the team had some trouble getting it working on our respective systems. Below is an example of one of the errors that were experienced.
3/8/19
Unfortunately, Dr. Eno was unable to meet this week so it was a less productive week than usual. The main goal was to start getting the code for the crystal calorimeter working.
3/6/19 - Finding out how much of the energy is escaping the calorimeter
In order to find out how much of the energy is actually being detected by the calorimeter, I ran 10 of the 5 Ge pi+ and looked at the histogram in root which showed the following:
As you can see, the detector is only finding about 70% of the total energy. Dr. Eno wanted us to check whether or not the energy is simply leaking out of the detector or disappearing.
So, she created some code that found how much energy is leaving the "world". I used this code to create a histogram which showed the mean energy leaving the world for each run and ended up with a histogram that ended up looking like this:
So obviously, you can see from the mean that not all of the energy that is not accounted for is due to leaving the calorimeter. Now, we have to figure out why so much energy is simply disappearing.
3/5/19 - Increasing width of the Calorimeter
In order to increase the width of the calorimeter, we once again had to adjust the specifications set in the B4DetectorConstruction.cc file. Instead of changing the number of layers, we adjusted the calorimeter xy size by making it equal to the (number of layers)*(thickness of each layer). When I ran another run of one 5 GeV pion+, I got the following.
It is important to note that this calorimeter has an astounding 235 layers.
Also, the reason why there may be so many particles that are going into the "wrong direction" may be seen in the theory that most of the hadronic shower are composed of neutrons.
3/4/19 - Increasing thickness of the Calorimeter
Unfortunately, it was obvious that a lot of energy was "leaking out" of the calorimeter. So, I had to make it significantly larger. Dr. Eno suggested that we take the "nuclear interaction length" for our passive layer element from this website - http://pdg.lbl.gov/2018/AtomicNuclearProperties/index.html - and make sure the thickness of the calorimeter is at least 10-20 of these. This was done simply through going into the B4DetectorConstruction.cc file and adjusting the #oflayers of the calorimeter. After completing this, one of the runs that we, as a team received looked like this.
Since it is clear that a TON of energy is leaking out the sides, Eno suggested that we make the calorimeter as wide as it was thick.
3/3/19 - Configuring an Esum Histogram
I was able to get the histogram of the Energy sum working on my personal pc. This is an example of what one of the histograms look like.
In order to get this histogram to be made in root, I had to add a histogram to the B4a/src files on my cluster account. I specifically had to alter B4RunAction.cc and B4aEventAction.cc
2/28/19 - Meeting With Dr. Eno
In our meeting with Dr. Eno this week, we learned how to make a histogram that calculates the sum of the energy deposited in both the active and passive layer.
We saw that the mean of the energy of these histograms did not add up to the energy at which the particle entered the calorimeter.
The thought is that some of the energy must be leaving the "world" and escaping the calorimeter.
2/24/19 - Gaussian fits
To make the histogram that was made even more useful, we can fit it to a Gaussian. At first, I ran into a few bugs while doing this. However, thanks to some help from my peers I was able to get it working. The commands I used to complete the task were the following:
It produces the following graph:
2/22/19 - Meeting #3 with Dr. Eno and Team
Dr. Eno wants us to create 6 plots
- Energy Scale Vs Particle Energy for electrons, charged pions, neutrons (5 energies atleast per graph)
- Energy resolution Vs Particle Energy for electrons, charged pions, neutrons (5 energies atleast per graph)
Resolution = rms value from histogram / mean energy of active layer
Energy Scale = mean energy of active layer (gap)
2/19/19 - Running Geant4 without Graphics/Changing Settings/Fitting to Histogram
First, I created a .mac file to change the setting of my run as I please. The syntax required to change the settings for GEANT is very simple.
An example of one of the adjustments I made to the default run:
/run/intialize #initializes the run
/gun/energy 500 MeV #changes the energy of each particle
/gun/particle mu+ #Changes the particle type to a positively charged muon
/run/beamOn 1000 #sets the number of particles in the stack to 1000
exit #Exits the simulation
In order to complete this run without graphics, one must go into the build directory (after setting up the environmental variables of course) and type the command:
./exampleB4a -m file.mac
Finally, since there is an immense amount of data (there were 1000 runs) we must find a way to analyze. A great way to do this is through a histogram. Through using root we can do just that.
Root automatically created histograms for each run that comes out of GEANT. In order to access them I simply needed to go into TBrowser and look in my Root files. Below is a screenshot of one of the histograms.
2/18/19 - Notes from Reading
Particle Resonance
- When two particles collide and end up being the same two particles they often create another particle for a very short moment when they interact.
- This particle then splits back up and turns back into the original two particles again.
- You can determine the lifetime of the temporary particle by looking at a graph of #of interactions vs KE.
- Take the range of KE of the graph halfway to the point where there is a peak of interactions
Hadron Calorimeter
- Both EM and Hadron calorimeters are used in the vast majority of cases
- Deposit 1/3-2/3 of energy into EMC anyway
- Used to detect protons, pions, kaons and fragmenting quarks and gluons (jets) with energies in the GeV–TeV range
- Fraction of energy contained in non-em component (invisible energy) does not contribute to measured energy
- The invisible energy can be up to 40%. This value fluctuates which contributes to a large degree of uncertainty.
Electromagnetic Calorimeter
- A calorimeter absorbs a fraction of the energy of an incident particle and produces a signal with amplitude proportional to that energy.
- It absorbs the energy through a multi-step process.
- The avg value of secondary particles (n) produced through this process is proportional to the "incident energy".
- A lot of the energy resolution problems come from the fact that the detected signal fluctuates. This means resolutions grows as sqrt(n) grows.
- So, as energy increases n increases proportionally and resolution, therefore, increases logarithmically.
2/15/19 - Meeting #2 with Dr. Eno
- Most calorimeters have both a Electromagnetic and Hadron Calorimeter.
- Hadron Calorimeter is bigger and cheaper. Usually on the outside to collect info that the EM calorimeter misses
- EM calorimeter collects info from electrons and photons mainly
- Hadron calorimeter often measure energy from things that may "get past" EM calorimeter. E.g. neutrally charged particles
- Only about 1% is picked up by the active layers of the calorimeter. The rest goes to the passive layers.
2/14/19 - Learning Geant4 Software
In order to get comfortable with the Geant4 software we first ran very simple simulations of a particle depositing its energy into a calorimeter. We ran it with graphics at first in order to give us a conceptual idea of what we'll be doing in the future. Later on, we'll void the graphics to speed up the process and allow us to throw thousands of particles at the calorimeter.
In order to get GEANT4 to work I had to set up the several environmental variables, cd to the build directory and run the ./exampleB4a file.
2/14/19 - Notes from Reading
W and Z bosons
- carry weak force
- very short range but about the same strength as em force
- vanishes beyond radius of a proton
- Z is neutrally charged but W+ and W- have 1 elementary charge.
- All have spin of 1
- By emitting a w boson the weak force can cause a proton to change its charge because of a change in flavor of quarks-
- Neutrinos interact only through the weak force
2/12/19 - Researching Physics Necessary for research
http://iasprogram.ust.hk/hep/2019/workshop_cc.php
http://ias.ust.hk/program/shared_doc/2019/201901hep/program/20190117_2042_am_Paolo% 20Giacomelli.pdf
https://www.sciencedirect.com/science/article/pii/S0168900211005572
https://www.sciencedirect.com/science/article/pii/S0168900211019851
http://www.hep.caltech.edu/~zhu/papers/08_tns_crystal.pdf
http://cepc.ihep.ac.cn/
2/6/19 - Started Setting up GEANT4
- At first, I was silly and tried to install it on Windows. While it is possible to install it in Windows it would be significantly more difficult since there is apparently an installing package in the CERN clusters which I will soon have access to.
- I ended up getting Ubuntu up and running on my Virtual Box and plan on working on the installation of GEANT4 once the clusters are back up.
2/2/19 - Met with Dr. Eno
- My partner and I met with Dr. Eno to discuss the general idea of the project. I will be working on running simulations for the calorimeter of the future (hopefully) CEPC collider.
- She explained how we use crystals to improve resolution on our experiments. They provide a scintillating effect which causes it requires less energy for a higher quality image.
- Also, she told us we should install GEANT4 and take a tutorial.
- We were provided with several scientific readings to more deeply understand the experiments we will be simulating.
HONR268N
11/27/18 (Date Completed) - HW10
What does the deep dreams algorithm do?
The google engineers created a neural network that was able to identify objects with some accuracy. Usually this would be used to name a picture or identify the same person in different photos as used in "Google Photos". However, for deep dreams they let the neural network run loose and actually change the picture in what they saw tendencies towards. For example, if the program sees the pattern that looks slightly like a cat in the pattern of cheerios in a cereal bowl it will exaggerate that pattern and make it seem even more like that cat. Each layer of the neural network adds more detail to that cat. The program over-exaggerates the details in every picture to make it seem almost eerie to the human eye. One can think of the deep dreams program as grasping at straws to identify objects that aren't really there and bringing those objects to life in the image.
Here are a couple of images I ended up with after running the code on a smiley face and clouds:
11/20/18 (Date Completed) - HW9
1. A CPU is considered the brains of the computer and handles all the computational processes. The GPU just handles the graphics and rendering.
2. The output was 30.
3. Finding area of a circle program
pi=3.14159 #Approx.
diameter=10 #Sets variable diameter = 10
radius = diameter/2 # Creates new variable called radius that is equal to diameter divided by 2
area = pi*radius*radius #Creates a new variable called area which is equal to the pi variable times the square of the radius variable.
print(area) #prints out the area variable
OUTPUT: 78.53975
4. Method 2 works because it has an extra placeholder variable to hold the variable that is being replaced first.
5. Code for switching goldfish, human, and dog variables.
dog_legs=0 #Sets the variable dog_legs equal to 0
human_legs=4 #Sets the variable human_legs equal to 4
goldfish_legs=2 # Sets variable goldfish_legs equal to 2
place = dog_legs # Creates a placeholder variable that records the value of dog_legs(0) at this point of time in the program.
dog_legs = human_legs #Takes the value of human_legs and sets it equal to dog_legs
place2 = goldfish_legs #Creates a second placeholder that holds the value of goldfish_legs at this point in the program
goldfish_legs=place #Sets the variable goldfish_legs equal to the first placeholder variable. This value is really just the original value of dog_legs before it was changed.
human_legs = place2 #Sets the human_legs variable equal to the 2nd place holder variable which is really just the original value of the goldfish_legs variable,
print(dog_legs) #Prints the value of dog_legs
print(human_legs) #Prints the value of human_legs
print(goldfish_legs) #Prints the value of goldfish_legs
OUTPUT:
4
2
0
6. Code for rounding program
def round_to_n_places(num, numOfPlaces): #Creates a method/function called round_to_n_places that has two parameters - num and numOfPlaces
{
return round(num, numOfPlaces) #returns the value of num rounded to number of places given by the variable numOfPlaces
}
print(round_to_n_places(5.434534, 2)) #Prints the value of the function with the given input values.
OUTPUT:
5.43
7. Output of code
cat
10
-543
645365
656743
3
[-543, 1, 3, 4, 23, 31, 324, 435, 5435, 5665, 645365]
8. List product of max code
a=[3243,645645,54346] #Creates a list/array of length 3 called "a"
b=[7,3,2] #Creates a list/array of length 3 called "b"
def product_of_maxes(blah, blah2): #Creates a method/function called product_of_maxes that has two parameters - blah and blah2
{
print(max(blah)*max(blah2)) #prints the product of the maximum value of list blah and list blah2
}
print(product_of_maxes(a,b)) #Prints the value of the product_of_maxes function when given the input values of list a and b. It should print the product of the maximum values of the lists a and b
OUTPUT:
4519515
9. Output of Boolean code
False
True
False
True
10. Self-made Boolean code
a = [231, 1232, 213] #Creates an array of length 3 called "a"
b = 1500 #sets a variable b to a value of 1500
print(sum(a)>b) #Prints either true or false, depending on whether the sum of all the contents of array a is greater than the value of variable b
OUTPUT:
True
11. Output of given Boolean code
20 is greater than 10
12. I can change the values to a = 20 b =20 and a =20 b = 10 to see the other outputs.
13. Output of code given:
jfkdla;s
abcfdsafdasg
None
14. The following line implies that you have 10 eggs, flour, and almond milk
15. When the code is entered in with 0 eggs the program returns that you are not able to make a cake.
16. Code for determining whether or not the absolute value of the min is odd
a = [-35423,-5432654,-352435,53252] #creates an array of length 4 named "a"
def abs_of_min_is_odd(array): #creates a function called abs_of_min_is_odd that takes has one parameter named array
if (abs(min(array))%2 ==1): #creates an if statement with the condition that the absolute value of the minimum value of the array modded by 2 has to equal 1. This can also be interpreted as the value must be odd.
print("the absolute value of the minimum of the list is odd") #prints the words inside quotation
else:
print("the absolute value of the minimum of the list is even") #prints the words in quotation if the previous condition is not satisfied
print(abs_of_min_is_odd(a)) #prints the results of the function named abs_of_min_is_odd when the array "a" is given as the input
OUTPUT:
the absolute value of the minimum of the list is even
17. Commented on the code
def select_third_element(my_list): #Creates a method/function called select_third_element that has one parameter - my_list
if(len(my_list) < 3): #creates an if statement with the condition that the length of the array must be less than 3
return None #exits the function without returning anything
else:
return my_list[2] #remember index 0, so third element is index 2. This line returns the 3rd element of the list provided/
foo = ['a', 'b', 'c', 'd'] #creates an array of length 4 with only strings of length 4
print(select_third_element(foo)) #prints the output of the function when the array foo is given as input. It should print the third element of the array which is c.
list1=[1,2,3] #creates an array of length 3 called list1
list2=[4,5,6] #creates an array of length 3 called list2
list_of_lists=[list1,list2] #Creates a 2x3 matrix with the values of list1 in the first row and the values of list2 in the second row.
print(list_of_lists[1][2])#prints out second row, 3rd element. This is the 3rd element of list2
print(list_of_lists[0])#prints out first row. this is list1
print(list_of_lists[1])#prints out second row. This is list2
print(list_of_lists[0][1])#prints out first row, 2nd element. This is the second element of the first list.
print(list_of_lists[0][2])#prints out first row, 3rd element. This is the 3rd element of list1
print(list_of_lists[1][0])#prints out second row, 1st element. This is the 1st element of list2
18. Wrote code to find losing captain
real_madrid=['zidane', 'ramos', 'marcelo'] #creates array of length 3 which name real_madrid
barcelona=['valverde', 'messi', 'pique']#creates array called barcelona of length 3
teams = [real_madrid, barcelona] creates a 2x3 matrix with the values of real_madrid in the first row and the values of barcelona in the second row
def losing_team_captain(team_list):
OUTPUT: messi
19. Mario purple shell program
standings=['mario', 'bowser', 'luigi','peach'] #creates an array called "standings" with length 4
def purple_shell(racers): #Creates a method/function called purple_shell that has one parameter called racers. Overall this function switches the first and last places of the array
first = racers[0] #assigns the variable called first to the value of the first element of the racers array
racers[0] = racers[3] #sets the 1st element in racers to the value in the 4th element in racers
racers[3] = first #sets the 4th element in racers to the variable first which was the original value of racers[0]
purple_shell(standings) #executes the function on the array "standings"
print(standings[0]) #prints the first value of standings
print(standings[3]) #prints the last value of standings
OUTPUT:
Peach
Mario
20. Divisible by 7 program
list=[1,21,7,-14,49,74,700] #creates an array called list that has length of 7
def seven_counter(my_list): #creates a function called seven_counter that takes one parameter called my_list. This function counts the number of elements in the array that is a multiple of 7.
counter = 0 #sets counter variable to 0
blah = range(0,len(my_list),1) #creates a variable that iterates over time to for the for loop. It will cause the loop to start at 0 iterate by 1 and end once it's reached the value of the length of the array my_list
for i in blah: #creates a for loop that iterates with the specs listed above
if abs(my_list[i])%7==0: #creates a conditional statement which requires that the absolute value of the (i+1)th element in the my_list array must be divisible by 7
counter = counter+1 #adds one to counter variable
print(counter) #prints counter variable
print(seven_counter(list)) #prints the value the function returns when given the input of the list array. It should print the number of elements in the list array that are divisible by 7
OUTPUT:
5
21. Card game program
deck={} #represents a deck of cards where the keys are the suits and values are lists of card values
hearts=[] #Creates an array called hearts with no elements
clubs=[] #Creates an array called clubs with no elements
diamonds=[] #Creates an array called diamonds with no elements
spades=[] #Creates an array called spades with no elements
values=['ace', 'two', 'three', 'four', 'five', 'six','seven', 'eight', 'nine', 'jack', 'king', 'queen'] #Creates an array called values with 12 elements
def create_cards(suit): #Creates a function called "create_cards" with one parameter called "suit"
for value in values: #creates a for loop that goes through all the elements of values and adds it to various ArrayLists
suit.append(value) #adds the element "value" to the suit list
create_cards(hearts) #inputs the value of the array hearts into this same function
create_cards(clubs) #inputs the value of the array clubs into this same function
create_cards(diamonds) #inputs the value of the array diamonds into this same function
create_cards(spades) #inputs the value of the array spades into this same function
deck.setdefault('h', hearts) # creates a value jokers with key "h"
deck.setdefault('s',spades) # creates a value jokers with key "s"
deck.setdefault('c', clubs) # creates a value jokers with key "c"
deck.setdefault('d', diamonds) # creates a value jokers with key "d"
print(deck.items()) #prints all of the items in deck array
print(deck.keys()) #prints all the keys in the deck array
print(deck.values()) #prints all the values in the deck array
deck.pop('s') #removes and returns the spade elements in the array deck
jokers=['joker1','joker2'] # creates array with 2 elements
deck.setdefault('j',jokers) # creates a value jokers with key "j"
deck.clear(); #removes all the elements from the deck ArrayList
OUTPUT:
dict_items([('h', ['ace', 'two', 'three', 'four', 'five', 'six', 'seven', 'eight', 'nine', 'jack', 'king', 'queen']), ('s', ['ace', 'two', 'three', 'four', 'five', 'six', 'seven', 'eight', 'nine', 'jack', 'king', 'queen']), ('c', ['ace', 'two', 'three', 'four', 'five', 'six', 'seven', 'eight', 'nine', 'jack', 'king', 'queen']), ('d', ['ace', 'two', 'three', 'four', 'five', 'six', 'seven', 'eight', 'nine', 'jack', 'king', 'queen'])])
dict_keys(['h', 's', 'c', 'd'])
dict_values([['ace', 'two', 'three', 'four', 'five', 'six', 'seven', 'eight', 'nine', 'jack', 'king', 'queen'], ['ace', 'two', 'three', 'four', 'five', 'six', 'seven', 'eight', 'nine', 'jack', 'king', 'queen'], ['ace', 'two', 'three', 'four', 'five', 'six', 'seven', 'eight', 'nine', 'jack', 'king', 'queen'], ['ace', 'two', 'three', 'four', 'five', 'six', 'seven', 'eight', 'nine', 'jack', 'king', 'queen']])
22.
23. My plot
import matplotlib #imports the matplotlib library
import matplotlib.pyplot as plt #imports the matplotlib.pyplot library and binds it to the name plt
import numpy as np #imports the numpy library land binds it to the name np
x = np.arange(-10,10,.01) #declares a independent varaible x that has a domain of -10 to 10 that increments by .01.
y = x**2 #creates a function y=x^2
plt.plot(x,y) #plots the function y=x^2 with a domain of -10 to 10 and an increment of .01
plt.xlabel('x-axis') #labels the x axis with title "x-axis"
plt.ylabel('y-axis') #labels the y-axis with title "y-axis"
plt.show() #displays the plot/graph
24. Output of code
11/13/18 (Date Completed) - HW7
HONR268N HW7
1. Beam Pipe – The pipe through which to particles travel through, eventually colliding.
Tracker – Tracks the trajectory of the particles after the collision has occurred. Radius of about 1.1 m
Calorimeter – Designed to measure with high accuracy the energies of particles. This has a radius of about 2.5m
Solenoid – A magnet made of coils of wire that produces a uniform magnetic field when electricity flows through them. Length of 13 meters and diameter of 7 meters.
Muon Detector – Because muons are picked up by calorimeter, muon detectors are needed to take data on the energy of muons. Diameter of 14 meters.
2. Press the coordinate axis at the top that has Z in the bottom left hand corner.
3. COLOR TRACKS:
Electrons – Green lines
Muons – Red Lines
Missing Energy – Dashed purple lines
Jets – Green Cones
4. By using the right-hand rule and assuming the magnetic field is coming out of the screen it is easy to see it counter clockwise.
4lepton:
Run / Event / LS: 178424 / 666626491 / 585
Electrons: 0
Photons: 0
Muons: 4
Missing Energy: 1
Jets: 48
Vertices: 5
Run / Event / LS: 193575 / 400912970 / 523
Electrons: 4
Photons: 0
Muons: 1
Missing Energy: 2
Jets: 55
Vertices: 11
Diphoton
Run / Event / LS: 199319 / 641436592 / 464
Electrons: 0
Photons: 2
Muons: 1
Missing Energy: 1
Jets: 26
Vertices: 11
Run / Event / LS: 199699 / 336259924 / 272
Electrons: 0
Photons: 2
Muons: 0
Missing Energy: 1
Jets: 24
Vertices:6
MinimumBias:
Run / Event / LS: 148031 / 441572355 / 553
Electrons: 0
Photons: 0
Muons: 0
Missing Energy: 0
Jets: 15
Vertices: 5
Run / Event / LS: 148031 / 441584555 / 553
Electrons: 0
Photons: 0
Muons: 0
Missing Energy: 0
Jets: 0
Vertices:1
Mu:
Run / Event / LS: 146436 / 90625265 / 322
Electrons: 0
Photons: 0
Muons: 0
Missing Energy: 0
Jets: 0
Vertices: 1
Run / Event / LS: 146436 / 90626440 / 322
Electrons: 0
Photons: 0
Muons: 1
Missing Energy: 0
Jets: 12
Vertices:3
Electrons:
Run / Event / LS: 146644 / 718940510 / 797
Electrons: 1
Photons: 2
Muons: 0
Missing Energy: 1
Jets: 13
Vertices: 1
Run / Event / LS: 146644 / 718948926 / 797
Electrons: 1
Photons: 1
Muons: 1
Missing Energy: 1
Jets: 16
Vertices:4
The following is an example of the Events being analyzed in HW7:
10/30/18
IN CLASS
Notes:
Ice cube project:
Cosmic rays are very high energy particles colliding and showering down "remains".
They're looking for a build up of neutrinos because they come from all sorts of directions.
Why Neutrinos? - Neutrinos are electrically neutral and carry info from deep into their origins.
Neutrinos are a unique signature of hadronic acceleration.
They look Cherenkov light is emitted
10/23/18
IN CLASS
Notes:
SdotS= t^2- mag(p)^2
Energy = eV=mc^2
Momentum = eV/c
Mass = ev/c^2
Natural units = c = h = 1
1ev = 1.6*10^-19
Higgs mass = 125 Gev
Invariant mass is not dependent on relativity.
Invariant mass = SdotS
Breit-Wigner
Detectors
mv^2/r=qvB
Root is god-tier excel
Get into the root prompt with root-l.
Shell scripting
10/22/18
Programming HW6 Practice Problems
IntroToArrays.cpp
#include <iostream>
using namespace std;
/************************************************\
* *
* Arrays *
* This program demonstrates arrays *
* *
\************************************************/
int main() {
int ii[3] = {1,2,3}; //this declares an array of size 3 and of int type.
int j=0; //sets integer value to 0
while (j<3) { //the loop will run until j is >= 3
cout <<" ii of "<<j<<" is "<<ii[j]<<endl; //will print the jth element of the array
j++; //adds one to j
}
int LL[2][3] = {1,2,3,4,5,6};//declares an array with 2 rows and 3 columns
j=0;
int k;
while (j<2) { //the loop will not stop until j is >=2
k=0;
while (k<3) { //this inner loop will not stop until k is >=3
cout<<" LL of "<<j<<" "<<k<<" is "<<LL[j][k]<<endl; //prints the values of j and k and then the corresponding array value at those row/column positions.
k++; // adds one to k
}
j++;//adds one to j
}
return 0;//exits program
}
//Side note: the commenting above shows an alternate way to comment out code.
OUTPUT:
[cms-opendata@localhost src]$ ./a.out
ii of 0 is 1
ii of 1 is 2
ii of 2 is 3
LL of 0 0 is 1
LL of 0 1 is 2
LL of 0 2 is 3
LL of 1 0 is 4
LL of 1 1 is 5
LL of 1 2 is 6
ReadingDataFromFile.cpp
#include <iostream>
#include <fstream>
using namespace std;
int main() {
ofstream myfile;//creates file variable named "myfile". It uninitialized
myfile.open("example.txt"); //sets myfile = to example.txt and opens the txt file
myfile<<"write some junk."; //writes "write some junk" into the file.
myfile.close();//closes example.txt
return 0;//exits program
}
OUTPUT:
[cms-opendata@localhost src]$ ./a.out
[cms-opendata@localhost src]$ cat ./example.txt
write some junk.
main.cpp
/* MAIN.CPP */
#include <iostream>
#include <fstream>
// include the program dotprod.cpp so that we can find the dot_prod function
#include "dotprod.cpp"
using namespace std;
int main () {
// declare the vectors
double vector1[3];//initializes array vector1 of length 3
double vector2[3];//initializes array vector2 of length 3
double scalar;//initializes scalar variable of type double
// open the input file
ifstream infile;
infile.open("vectors.txt");
// store the input in the vectors and print the vectors for the user
infile>>vector1[0]>>vector1[1]>>vector1[2];
cout<<" Vector 1 is ("<<vector1[0]<<","<<vector1[1]<<","<<vector1[2]<<")"<<endl;
infile>>vector2[0]>>vector2[1]>>vector2[2];
cout<<" Vector 2 is ("<<vector2[0]<<","<<vector2[1]<<","<<vector2[2]<<")"<<endl;
infile>>scalar;
cout<<" The scalar is "<< scalar<<endl;
// close the input file
infile.close();
// call the dot_prod function from dotprod.cpp
dot_prod(vector1,vector2);
int j = 0;//sets variable j to 0
while(j<3){//the loop won't stop until j >= 3
vector1[j]=vector1[j]*scalar;//multiplies every element in vector1 array by the scalar
vector2[j]=vector2[j]*scalar;//does the same for vector2 array
j++;//adds one to j
}
cout<<" The scalar multiple of vector 1 is ("<<vector1[0]<<","<<vector1[1]<<","<<vector1[2]<<")"<<endl;//prints out the new value for vector 1
cout<<" The scalar multiple of vector 2 is ("<<vector2[0]<<","<<vector2[1]<<","<<vector2[2]<<")"<<endl;//prints the new value for vector 2
return 0;//exits program
}
OUTPUT:
Vector 1 is (1,2,3)
Vector 2 is (4,5,6)
The scalar is 7
The dot product is 32
The scalar multiple of vector 1 is (7,14,21)
The scalar multiple of vector 2 is (28,35,42)
10/18/18
IN CLASS
Magnetic field - changes direction
Electric Fields - change speed
Cross section - probability of an interaction of a certain kind in a collider.
Luminosity - How many protons are hitting a cross-sectional area.
L = f*N^2/(4pi*sigma^2)
10/16/18
IN CLASS
Things needed to make an accelerator
1. Protons - Strip Hydrogen of electrons
2. Linac - Linear Accelerator
3. Inject into round accelerators with a magnetic field. Leading up to the largest collider
4. Split particles so they can collide.
5. Use detectors to watch them collide.
Logic Program #1
#include <iostream>
using namespace std;
int main() {
int n = 10; //sets n equal to 10
while (n>=10) { // sets the loop to stop when it is less than 10
if(n>5) { //sets conditional statement for when n is greater than 5
cout<<"n is "<<n<<endl; //if n is greater than 5 it will print "n is [value of n]
}
else {
cout<<"n = "<<n<<endl; //if n is not greater than 5 it prints " n = [value of n]"
n--; //subtracts one from n
}
return 0; //exits program
}
}
OUTPUT: n is 10
Pointer Program #1
#include <iostream>
using namespace std;
int main() {
int i = 10;
cout << "The memory address of i is " << &i << "\n";//prints the statement followed by the pointer address.
cout << "The data stored at memory address " << &i << " is " << i << "\n";//prints the pointer address followed by the value stored at that address.
int* p = &i;//sets p = to the pointer address of variable i.
cout << "The value of p is " << p << "\n"; //prints value of p
cout << "We say that p 'points at' the memory location referenced by address " << p << "\n";//prints statement followed by value of p.
cout << "The data stored at memory address " << p << " is " << *p << "\n";//prints the pointer adress of i followed by the value of i.
return 0;//exits program.
}
OUTPUT:
[cms-opendata@localhost CMSSW_5_3_32]$ ./a.out
The memory address of i is 0x7ffe472d71a4
The data stored at memory address 0x7ffe472d71a4 is 10
The value of p is 0x7ffe472d71a4
We say that p 'points at' the memory location referenced by address 0x7ffe472d71a4
The data stored at memory address 0x7ffe472d71a4 is 10
PROGRAMMING FOR HW
Computational HW5 Question 1
#include <iostream>
using namespace std;
int main(){
int counter = 10; //set a variable of int type equal to 10
while (counter>0){ //declared that the loop will not stop until counter is <= to 0.
cout<<"The variable is now "<<counter<<".";//This statement will print out every time the loop occurs. It is just making sure the user knows what the variable's value is at this point in the program.
if(counter%2==0) //counter%2 outputs the remainder of counter after it has been divided by 2. Therefore, if the remainder is 0, the counter is even and if the remainder is 1 then it is odd.
cout<< " This number is even because " <<counter<< " mod 2 is equal to 0."<<endl;
else //This is for the case where the remainder is 1
cout<< " This number is odd because "<< counter<<" mod 2 is equal to 1."<<endl;
counter--; //subtracts one from counter
}
cout<<"The variable reached 0 so the loop has stopped"<<endl;//This is outside the scope of the loop so it will not print until after the loop is over.
}
OUTPUT:
[cms-opendata@localhost CMSSW_5_3_32]$ ./a.out
The variable is now 10. This number is even because 10 mod 2 is equal to 0.
The variable is now 9. This number is odd because 9 mod 2 is equal to 1.
The variable is now 8. This number is even because 8 mod 2 is equal to 0.
The variable is now 7. This number is odd because 7 mod 2 is equal to 1.
The variable is now 6. This number is even because 6 mod 2 is equal to 0.
The variable is now 5. This number is odd because 5 mod 2 is equal to 1.
The variable is now 4. This number is even because 4 mod 2 is equal to 0.
The variable is now 3. This number is odd because 3 mod 2 is equal to 1.
The variable is now 2. This number is even because 2 mod 2 is equal to 0.
The variable is now 1. This number is odd because 1 mod 2 is equal to 1.
The variable reached 0 so the loop has stopped
Computation HW5 Question 2
#!/bin/tcsh
set month = `date | awk '{print $2}'` #Sets the variable "month" equal to the second column in the date command.
ls -lat | grep "$month" #ls -lat lists all the files in the directory. grep looks for the keyword in $month and picks all of the lines that have said keyword in them.
OUTPUT:
[cms-opendata@localhost CMSSW_5_3_32]$ ./filesupdatedmonth.tcsh
drwxr-xr-x 18 cms-opendata cms-opendata 4096 Oct 16 17:10 .
-rwxrwxr-x 1 cms-opendata cms-opendata 294 Oct 16 17:10 filesupdatedmonth.tcsh
-rwxrwxr-x 1 cms-opendata cms-opendata 8707 Oct 16 16:48 a.out
-rw-rw-r-- 1 cms-opendata cms-opendata 1034 Oct 16 16:48 whileandif.cpp
-rw-rw-r-- 1 cms-opendata cms-opendata 1021 Oct 16 16:46 whileandif.cpp~
-rwxrwxr-x 1 cms-opendata cms-opendata 76 Oct 16 11:57 filesupdatedmonth.tcsh~
drwxr-xr-x 4 cms-opendata cms-opendata 4096 Oct 8 15:33 src
drwx------ 19 cms-opendata cms-opendata 4096 Oct 2 11:04 ..
Click on the subpages below to navigate my logbook.