Jump to content
Main menu
Main menu
move to sidebar
hide
Navigation
Main page
Recent changes
Random page
Help about MediaWiki
Luter 345 Experiments
Search
Search
Appearance
Create account
Log in
Personal tools
Create account
Log in
Pages for logged out editors
learn more
Contributions
Talk
Editing
Results
(section)
Page
Discussion
English
Read
Edit
Edit source
View history
Tools
Tools
move to sidebar
hide
Actions
Read
Edit
Edit source
View history
General
What links here
Related changes
Special pages
Page information
Get shortened URL
Appearance
move to sidebar
hide
Warning:
You are not logged in. Your IP address will be publicly visible if you make any edits. If you
log in
or
create an account
, your edits will be attributed to your username, along with other benefits.
Anti-spam check. Do
not
fill this in!
==Writing Root Macro== In order to simplify and streamline the analysis, a macro can be designed to read in multiple files at one time and produce several histograms of the data. Furthermore, fitting the data and illustrating the length dependence for multiple trials helps in visualizing possible errors in the data or in the analysis. === Creation === Root provides a data analysis framework that allows for program creation using a built-in C++ interpreter. Becoming familiar with Root will be key in writing functional macros that will efficiently and easily analyze our data. Some helpful documentation has been provided by CERN to aid in learning specific functions of the framework. For instance, the following link provides an example for basic graphing syntax: http://root.cern.ch/root/html/tutorials/graphs/graph.C.html This type of example-based documentation may prove to be invaluable in creating Root macros. === Helpful Starting Tips === For the purposes of this experiment, histograms, graphs, fitting functions, and file I/O are going to be key for the data analysis. Below are some helpful hints on how to design such a program: '''1. Have a Plan''' Creating a program needs some preparation. Thinking about the end result and what you intend to produce will help greatly in designing an efficient macro. For instance, planning out possible variables, methods for parsing the data, and displaying the data can really help guide one through the creation process. '''2. Scope''' Along with the planning, ideas around how much data you are handling will help in deciding how to create a certain function. For example, say one experiment required five histograms to be created along with a single plot of average time versus cable length. This would be easy to simply have 5 separate Canvases with 5 different histograms and then a second Canvas to display the average time plot. But if there were 50 histograms that were going to be analyzed, a different approach would be needed for the creation of the histograms and how they are going to be displayed. '''3. Attempt''' Usually, a first attempt is never perfect, so do not be afraid to try something. Trial and error is going to be the best form of practice in discovering the best way to conduct the data analysis. === Useful Syntax === '''1. Having a Root File''' Machine-Independent binary file creation: ''TFile *f = new TFile("junk2.root","RECREATE");'' Helpful link: http://root.cern.ch/drupal/content/accessing-root-file '''2. Creating Histograms''' To create a single histogram pointer: ''TH1F *h1 = new TH1F("h1","x distribution",10000,0.0,1.0);'' '''3. Creating Canvases''' Single area mapped to a window for something to be displayed: ''TCanvas *c1 = new TCanvas("c1","Hists with different scales",2000,1000);'' Helpful link: http://root.cern.ch/root/html/TCanvas.html '''4. Pads''' Dividing the canvas into columns and rows: ''c1->Divide(4,5);'' Helpful link: http://root.cern.ch/drupal/content/canvases-and-pads '''5. File I/O''' String formatting might be a possible way of scanning each file: ''sprintf(name, "exp0_trial'''%d'''.txt",1);'' Scanning file: ''fscanf(fp,"%f %f",&'''column1''', &'''column2''');'' Helpful hint: TString has a function called Form() that can manipulate strings. '''6. Graphing''' Basic graph creation: ''graph = new TGraph(2,length,average_time);'' Helpful link: ftp://root.cern.ch/root/doc/4Graphs.pdf
Summary:
Please note that all contributions to Luter 345 Experiments may be edited, altered, or removed by other contributors. If you do not want your writing to be edited mercilessly, then do not submit it here.
You are also promising us that you wrote this yourself, or copied it from a public domain or similar free resource (see
Luter 345 Experiments:Copyrights
for details).
Do not submit copyrighted work without permission!
Cancel
Editing help
(opens in new window)