|
Updates and Results
Talks and Posters
Advice
Ideas
Important Figures
Write-Ups
Outreach
How-To
Funding Opportunities
GENETIS
|
| Place to document instructions for how to do things |
 |
|
|
Message ID: 33
Entry time: Mon Feb 11 21:58:26 2019
|
| Author: |
Brian Clark |
| Subject: |
Get a quick start with icemc on OSC |
| Project: |
Software |
|
|
Follow the instructions in the attached "getting_started_with_anita.pdf" file to download icemc, compile it, generate results, and plot those results. |
|
# .bash_profile
# Get the aliases and functions
if [ -f ~/.bashrc ]; then
. ~/.bashrc
fi
# User specific environment and startup programs
PATH=$PATH:$HOME/.local/bin:$HOME/bin
export PATH
|
|
|
//C++ includes
#include <iostream>
//ROOT includes
#include "TCanvas.h"
#include "TStyle.h"
#include "TH1D.h"
#include "TFile.h"
#include "TTree.h"
using namespace std;
int main(int argc, char *argv[])
{
if(argc<2)
{
cout << "Not enough arguments! Stop run. " << endl;
return -1;
}
/*
we're going to make a histogram, and set some parameters about it's X and Y axes
*/
TH1D *nuflavorint_hist = new TH1D("nuflavorint", "",3,1,4);
nuflavorint_hist->SetTitle("Neutrino Flavors");
nuflavorint_hist->GetXaxis()->SetTitle("Neutrino Flavors (1=e, 2=muon, 3=tau)");
nuflavorint_hist->GetYaxis()->SetTitle("Weigthed Fraction of Total Detected Events");
nuflavorint_hist->GetXaxis()->SetTitleOffset(1.2);
nuflavorint_hist->GetYaxis()->SetTitleOffset(1.2);
nuflavorint_hist->GetXaxis()->CenterTitle();
nuflavorint_hist->GetYaxis()->CenterTitle();
for(int i=1; i < argc; i++)
{ // loop over the input files
//now we are going to load the icefinal.root file and draw in the "passing_events" tree, which stores info
string readfile = string(argv[i]);
TFile *AnitaFile = new TFile(( readfile ).c_str());
cout << "AnitaFile" << endl;
TTree *passing_events = (TTree*)AnitaFile->Get("passing_events");
cout << "Reading AnitaFile..." << endl;
//declare three variables we are going to use later
int num_pass; // number of entries (ultra-neutrinos);
double weight; // weight of neutrino counts;
int nuflavorint; // neutrino flavors;
num_pass = passing_events->GetEntries();
cout << "num_pass is " << num_pass << endl;
/*PRIMARIES VARIABLES*/
//set the "branch" of the tree which stores specific pieces of information
passing_events->SetBranchAddress("weight", &weight);
passing_events->SetBranchAddress("nuflavor", &nuflavorint);
//loop over all the events in the tree
for (int k=0; k <=num_pass; k++)
{
passing_events->GetEvent(k);
nuflavorint_hist->Fill(nuflavorint, weight); //fill the histogram with this value and this weight
} // CLOSE FOR LOOP OVER NUMBER OF EVENTS
} // CLOSE FOR LOOP OVER NUMBER OF INPUT FILES
//set up some parameters to make things loo pretty
gStyle->SetHistFillColor(0);
gStyle->SetHistFillStyle(1);
gStyle->SetHistLineColor(1);
gStyle->SetHistLineStyle(0);
gStyle->SetHistLineWidth(2.5); //Setup plot Style
//make a "canvas" to draw on
TCanvas *c4 = new TCanvas("c4", "nuflavorint", 1100,850);
gStyle->SetOptTitle(1);
gStyle->SetStatX(0.33);
gStyle->SetStatY(0.87);
nuflavorint_hist->Draw("HIST"); //draw on it
//Save Plots
//make the line thicker and then save the result
gStyle->SetHistLineWidth(9);
c4->SaveAs("nuflavorint.png");
gStyle->SetHistLineWidth(2);
c4->SaveAs("nuflavorint.pdf");
delete c4; //clean up
return 0; //return successfully
}
|
|
|
|
|
# Makefile for the ROOT test programs. # This Makefile shows nicely how to compile and link applications
# using the ROOT libraries on all supported platforms.
#
# Copyright (c) 2000 Rene Brun and Fons Rademakers
#
# Author: Fons Rademakers, 29/2/2000
include Makefile.arch
################################################################################
# Site specific flags
################################################################################
# Toggle these as needed to get things to install
#BOOSTFLAGS = -I boost_1_48_0
# commented out for kingbee and older versions of gcc
ANITA3_EVENTREADER=1
# Uncomment to enable healpix
#USE_HEALPIX=1
# Uncomment to disable explicit vectorization (but will do nothing if ANITA_UTIL is not available)
#VECTORIZE=1
# The ROOT flags are added to the CXXFLAGS in the .arch file
# so this should be simpler...
ifeq (,$(findstring -std=, $(CXXFLAGS)))
ifeq ($(shell test $(GCC_MAJOR) -lt 5; echo $$?),0)
ifeq ($(shell test $(GCC_MINOR) -lt 5; echo $$?),0)
CXXFLAGS += -std=c++0x
else
CXXFLAGS += -std=c++11
endif
endif
endif
################################################################################
# If not compiling with C++11 (or later) support, all occurrences of "constexpr"
# must be replaced with "const", because "constexpr" is a keyword
# which pre-C++11 compilers do not support.
# ("constexpr" is needed in the code to perform in-class initialization
# of static non-integral member objects, i.e.:
# static const double c_light = 2.99e8;
# which works in C++03 compilers, must be modified to:
# static constexpr double c_light = 2.99e8;
# to work in C++11, but adding "constexpr" breaks C++03 compatibility.
# The following compiler flag defines a preprocessor macro which is
# simply:
# #define constexpr const
# which replaces all instances of the text "constexpr" and replaces it
# with "const".
# This preserves functionality while only affecting very specific semantics.
ifeq (,$(findstring -std=c++1, $(CXXFLAGS)))
CPPSTD_FLAGS = -Dconstexpr=const
endif
# Uses the standard ANITA environment variable to figure
# out if ANITA libs are installed
ifdef ANITA_UTIL_INSTALL_DIR
ANITA_UTIL_EXISTS=1
ANITA_UTIL_LIB_DIR=${ANITA_UTIL_INSTALL_DIR}/lib
ANITA_UTIL_INC_DIR=${ANITA_UTIL_INSTALL_DIR}/include
LD_ANITA_UTIL=-L$(ANITA_UTIL_LIB_DIR)
LIBS_ANITA_UTIL=-lAnitaEvent -lRootFftwWrapper
INC_ANITA_UTIL=-I$(ANITA_UTIL_INC_DIR)
ANITA_UTIL_ETC_DIR=$(ANITA_UTIL_INSTALL_DIR)/etc
endif
ifdef ANITA_UTIL_EXISTS
CXXFLAGS += -DANITA_UTIL_EXISTS
endif
ifdef VECTORIZE
CXXFLAGS += -DVECTORIZE -march=native -fabi-version=0
endif
ifdef ANITA3_EVENTREADER
CXXFLAGS += -DANITA3_EVENTREADER
endif
ifdef USE_HEALPIX
CXXFLAGS += -DUSE_HEALPIX `pkg-config --cflags healpix_cxx`
LIBS += `pkg-config --libs healpix_cxx`
endif
################################################################################
GENERAL_FLAGS = -g -O2 -pipe -m64 -pthread
WARN_FLAGS = -W -Wall -Wextra -Woverloaded-virtual
# -Wno-unused-variable -Wno-unused-parameter -Wno-unused-but-set-variable
CXXFLAGS += $(GENERAL_FLAGS) $(CPPSTD_FLAGS) $(WARN_FLAGS) $(ROOTCFLAGS) $(INC_ANITA_UTIL)
DBGFLAGS = -pipe -Wall -W -Woverloaded-virtual -g -ggdb -O0 -fno-inline
DBGCXXFLAGS = $(DBGFLAGS) $(ROOTCFLAGS) $(BOOSTFLAGS)
LDFLAGS += $(CPPSTD_FLAGS) $(LD_ANITA_UTIL) -I$(BOOST_ROOT) -L.
LIBS += $(LIBS_ANITA_UTIL)
# Mathmore not included in the standard ROOT libs
LIBS += -lMathMore
DICT = classdict
OBJS = vector.o position.o earthmodel.o balloon.o icemodel.o signal.o ray.o Spectra.o anita.o roughness.o secondaries.o Primaries.o Tools.o counting.o $(DICT).o Settings.o Taumodel.o screen.o GlobalTrigger.o ChanTrigger.o SimulatedSignal.o EnvironmentVariable.o source.o random.o
BINARIES = test_plot$(ExeSuf)
################################################################################
.SUFFIXES: .$(SrcSuf) .$(ObjSuf) .$(DllSuf)
all: $(BINARIES)
$(BINARIES): %: %.$(SrcSuf) $(OBJS)
$(LD) $(CXXFLAGS) $(LDFLAGS) $(OBJS) $< $(LIBS) $(OutPutOpt) $@
@echo "$@ done"
.PHONY: clean
clean:
@rm -f $(BINARIES)
%.$(ObjSuf) : %.$(SrcSuf) %.h
@echo "<**Compiling**> "$<
$(LD) $(CXXFLAGS) -c $< -o $@
|