#!/usr/bin/env run-groovy /**************************************************************** * Tutorial for CLAS12 analysis 22-sep-30 * Coatjava Version: 8.2.2 * ************************************************************** ~ ~ * ************************************************************** * How to Run (on my account on ifarm1901): * setenv JAVA_HOME /group/clas12/packages/jdk/11.0.2 * setenv COATJAVA /group/clas12/packages/coatjava/8.2.2 * * Usage: $COATJAVA/bin/run-groovy j2rootTutorial.groovy .hipo * data files exist in places like the following: * /cache/clas12/rg-a/production/recon/fall2018/torus-1/pass1/v1/dst/train/ePiNCND/ * * Output: rootfile/tutorialHists1.root (in rootfile area, you can creat your own or not) * tutorialHists1.hipo (in area j2rootTutorial.groovy) * (delete these two files if you run the code again.) * * ****************************************************************/ // imports (probably don't need all of them) ##################### // for reconstruction data import org.jlab.io.evio.*; import org.jlab.io.hipo.*; // for histograms import org.jlab.groot.data.TDirectory; import org.jlab.groot.data.H1F; import org.jlab.groot.data.H2F; import org.jlab.groot.ui.TCanvas; // for vectors import org.jlab.geom.prim.Vector3D; // for Geometry and Swimming import org.jlab.clas.physics.Particle; import org.jlab.detector.base.GeometryFactory; import org.jlab.detector.base.DetectorType; import org.jlab.clas.fastmc.*; import org.jlab.geom.prim.Line3D; import org.jlab.geom.prim.Shape3D; import org.jlab.geom.prim.Plane3D; import org.jlab.geom.prim.Point3D; import org.jlab.geom.detector.ec.ECSector; import org.jlab.geom.detector.ec.ECSuperlayer; import org.jlab.geom.detector.ec.ECLayer; import org.jlab.geom.base.ConstantProvider; import org.jlab.geom.detector.ec.ECFactory; import org.jlab.geom.detector.ec.ECDetector; // for Objects import java.lang.Math; import java.util.ArrayList; import java.text.DecimalFormat; // to create root output <---- really need these!!!!!! import org.jlab.jroot.ROOTFile import org.jlab.jroot.TNtuple // create a histogram and directories in memory. ****** TDirectory histFile = new TDirectory(); H1F hpmag; histFile.mkdir("/hists"); histFile.cd("/hists"); hpmag = new H1F("hpmag",110,0,11); hpmag.setFillColor(33); hpmag.setTitle("p[0] magnitude"); hpmag.setTitleX("p [GeV/c]"); histFile.addDataSet(hpmag); // add histogram to memory // create ROOT output file. def root_out = new ROOTFile("rootfile/tutorialHists1.root") // create an ntuple ********* def myNT = root_out.makeNtuple('nt1', 'my title', 'x:y:z') // First argument is the input file name String inputFile = args[0]; // Create coatjava object to read in the data file HipoDataSource reader = new HipoDataSource(); reader.open(inputFile); System.out.println("-----------> Reading File: [" + inputFile + "]\n"); // create an event HipoDataEvent event; // keep track of counts int nEvents = 1; // start at first event // loop over all events (or as many as you want). $$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$ int nEventsMax=2000; System.out.println("-----------> Here we go...\n"); while(reader.hasEvent() && (nEvents