Code Monkey home page Code Monkey logo

clas12tool's Introduction

Clas12Tool

Data Analysis Tools for HIPO data format.

Seperate code is provided for hipo3 and hipo4 format. The corresponding directories, libraries and binaries have an additional 3 or 4 to distinguish. Users are responsible for using the correct format for their hipo files.

Examples are given for running in interactive ROOT sessions and ROOT-Jupyter notebooks.

HipoX -> Clas12BanksX -> Clas12Root

The Hipo c++ reader library can be used independent of specific banks and ROOT, but depends on Hipo.

The Clas12Banks implementation can be used independent of ROOT, although currently ROOT dictionaries are created for the classes via cmake (this could be removed). This defines the specific CLAS12 DST banks and provides an interface to the data.

The Clas12Root package depends on both Hipo and Clas12Banks. This provides ROOT-like analysis tools for operating on clas12 hipo DSTs.

HipoDraw
HipoTreeMaker
HipoProof

To Download

git clone --recurse-submodules https://github.com/dglazier/Clas12Tool.git

cd Clas12Tool

To setup Run ROOT

setenv CLAS12TOOL $PWD (the actual path can be added in your bashrc or tchrc)

setenv PATH "$PATH":"$CLAS12TOOL/bin"

To install (either Hipo3 or Hipo4)

installHipo3 and/or installHipo4

If there are issues with cmake and your ROOTSYS you can try using the local FindROOT file. Edit the CMakeList.txt.hipo3 or 4 files removing the lines with comment ##USEROOTSYS and uncomment the line

 #######include("cmake/FindROOT.cmake")

interactive root session

To start an interactive session with pre-loaded Clas12Root us clas12root3 or clas12root4 instead of root on the command line.

Ex 1 Looping over events and getting particle information

The clas12reader class performs the correlation of particle and detector inofmation (aka reverse indexing). When looping over particles you are looping over region_particle (see Clas12Banks for full reference). Each region, FT, FD and CD has its own definition of a region_particle so it will only return meaningful data (i.e. a CD particle will return 0 for FD detector information). In addition the getTime, getPath, getDetEnergy functions have predefined meaning for each region, e.g. for FT getTime returns FTCAL time, for FD it returns FTOF1A if it exists, if not it will try FTOF1B, FTOF2 then PCAL.

You can insepct the code $CLAS12TOOL/RunRoot/Ex1_CLAS12Reader.C for more guidance on how to use it.

To run (for hipo3 replace the 4 with a 3):

   clas12root4 $CLAS12TOOL/RunRoot/Ex1_CLAS12Reader.C+ --in=/WHERE/IS/MY/HIPO/file.hipo

Note the use of the + sign after the macro name. This compiles the script meaning it will run much faster.

Jupyter

To install rootbooks see https://root.cern.ch/how/how-create-rootbook

mkdir myNotebooks

cp -r $CLAS12TOOL/RunRoot/jupy myNotebooks/.

cd myNotebooks/jupy

Start a ROOT note book :

  	root --notebook

Click on the notebook CLAS12Reader3Pi.ipynb and follow the tutorial

Ex 2 Drawing particle histograms from hipo files

   particleDraw4 /WHERE/IS/MY/HIPO/file.hipo

You will get an interactive ROOT prompt where you can draw histograms:

ParticleHist [0] hists.Hist1D("P.P",100,0,10,"P.P")
ParticleHist [1] hists.Hist2D("P.P:P.DetEnergy",100,0,10,100,0,5,"P.P")->Draw("(2x1)")

Note you only have to call draw once, and then it only has to loop over the date once. The option (2x1) specifies the dimensions of the pads in the produced canvas, the parenthesis is required.

Remember at the end you can save all the histograms to file :

ParticleHist [0] hists.Save("HistFile.root");

Instead of drawing histograms interactively at the prompt you may give predefined histograms via a script e.g. :

particleDraw4 /WHERE/IS/MY/HIPO/file.hipo Ex2_HipoDraw.C

See $CLAS12TOOL/RunRoot/Ex2_HipoDraw.C for details.

There are predefined aliases for DST bank detector layers :

    ECIN. , ECOUT. , PCAL. , FTOF1A. , FTOF1B. , FTOF2. , CTOF. , CND1. , CND2. , CND3. , FTCAL. , FTHODO. , HTCC. , LTCC. , DC. , CVT. 
    e.g. ECIN.Energy  , HTCC.Nphe , DC.TrChi2 , CTOF.Time

The REC::Particle bank should be directly accessed with

    PBANK.
    e.g. PBANK.Pid , PBANK.Px

The region particle should be accessed with

    P.
    e.g. P.Theta , P.P , P.Phi , P.Region , P.Time , P.DetEnergy , P.DeltaEnergy , P.Path , P.Pid , P.CalcMass
e.g. P.Region==FT,  P.Region==FD

Jupyter

Start a ROOT note book :

  	root --notebook

Click on the notebook HipoDraw.ipynb and follow the tutorial

Ex 4 Filtering and Skimming into a ROOT ntuple (tree)

   particleTree4  /WHERE/IS/MY/HIPO/file.hipo /OUTPUT/tree.root Ex4_TreeMaker.C

The script $CLAS12ROOT/RunRoot/Ex4_TreeMaker.C defines which branches are to be written and what cuts to put on the event topology. You can copy and edit this file to do what you want e.g.

 treemaker.Branch("P.Time/F"); //create tree with time branch
 treemaker.Branch("PBANK.Px/F"); //create tree with particle Px branch


 treemaker.AddExactPid(11,1); //filter events with exactly 1 e-
 treemaker.AddAtLeastPid(211,1);//and at least 1 pi+
 treemaker.AddZeroOfRestPid(); //and zero of any other particle type (default is any)

Jupyter

Start a ROOT note book :

  	root --notebook

Click on the notebook HipoToRootTree.ipynb and follow the tutorial

Ex 3 Using HipoSelector & PROOFLite

ONLY FOR HIPO4

This assumes you are aware of and understand the ROOT TSelector and PROOF scheme. See https://root.cern.ch/proof.

Create a HipoSelector (similar to tree->MakeSelector("mySelector");), using the executable makeHipoSelector :

   makeHipoSelector mySelector

You should use some meaningful name rather than mySelector. Edit it to perform the tasks you would like. But use the ProcessEvent function instead of the Process function as you would in a TSelector. You can use the _c12 clas12reader object to access all the data as shown in Ex1_CLAS12Reader.C

e.g.

 Bool_t HipoFileSelector::ProcessEvent(){

    _hist1->Fill(_c12->head()->getStartTime());
	    return kTRUE;    
 }

To execute :

   clas12proof4 4 mySelector.C Ex3_ProofLite.C

Note 4 = number of workers used, you should change this to however many you would like.

Note mySelector is hard-coded in Ex3_ProofLite.C so for your own selector you should copy and edit this script.

Jupyter

Start a ROOT note book :

  	root --notebook

Click on the notebook CreateHipoSelector.ipynb and follow instructions. This creates the selector you wish to run.

Once this is complete you should open the notebook HipoProof.ipynb and process the selector with PROOF

clas12tool's People

Contributors

dglazier avatar fbossu avatar gavalian avatar tylern4 avatar

Stargazers

 avatar

Watchers

 avatar  avatar  avatar

clas12tool's Issues

Segmenation Fault

Gives a seg fault when reading from the bank exceeds number of rows.

Dictionary issue

When dictionary is not read, or does not contain the schema,
bank is not properly initialized, add a warning.

clear bank when not in the event

I noticed that if a bank is read in event N, but the bank is not present in the event N+1, still the bank retains the previous event.

time_point error from hipo3 library

At Hipo/utils.h, line 55
std::chrono::time_point<std::chrono::steady_clock> first, second;
causes a compile error at ifarm at least to me.

I'd suggest
std::chrono::time_point<std::chrono::high_resolution_clock> first, second;
as in the Hipo4/utils.h.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.