AlexeyBoldyrev - 2016-02-16


  • Find by name:
find . -name "filename"

  • Find the word foo in files recursively:
grep -r "foo" .

  • Rename sample.root to 2HDM_800.root recursively:
find . -iname "*sample.root*" -exec rename sample.root 2HDM_800.root '{}' \;

  • Compare two files including line permutations
diff <(sort file1) <(sort file2)

  • Display 19th line from the end of the file
awk -v n=$n '{x[NR%19]=$0}END{print x[(NR+1)%19]}' file.txt

ROOT tips

Get list of branches
  • root -l file.root
  • nominal->MakeClass()

Open a root file, then Print() and Scan() it.
  TFile f("wp.root" ) ;
  TTree *t = f.Get( "AOphysics" ) ;
  t->Print() ;
  t->Scan( "EVT", "passIso==1&&wLJ==1" ) ;
Example: physics->Scan("EventNumber:el_n:mu_n:tau_n:trk_n:jet_n:mcevt_weight:mc_n","EventNumber==10441484")

How to check duplicate events in a TTree?
root[0] myTree->SetScanField(0);
root[1] myTree->Scan("eventNb:runNb:LS:zVtx:Reco_QQ_4mom.M()"); >tree.log
$ wc -l tree.log
$ sort -u tree.log | wc -l
If the tree has duplicated events, both wc -l will not give same number of lines.

Draw variables with a selection using GUI

  • Mouse right click on the your Tree of "Files" panel/tab. Select StartViewer
  • Drag and drop your variable into X:
  • Drag and drop your cut variable into Scissors
  • Mouse right click on the Scissors. Select EditExpression and put desired selection

Draw variables from command line
  • TFile *f = new TFile("ttbar.root", "READ");
  • nominal->Draw("Centrality_all")
  • nominal->Draw("Centrality_all","weight_mc>0","same")

Draw normalised variables at the same canvas
Double_t scale = 1/pos.Integral()
Double_t scale2 = 1/neg.Integral()

ROOT >6.06 features

Special variables
  • Alt$(primary,alternate) : return the value of "primary" if it is available for the current iteration otherwise return the value of "alternate". For example, with arr1[3] and arr2[2]
  • Entry$ : return the current entry number (same as TTree::GetReadEntry())
  • LocalEntry$ : return the current entry number in the current tree of a chain (same as GetTree()->GetReadEntry())
  • Entries$ : return the total number of entries (same as TTree::GetEntries())
  • Length$ : return the total number of element of this formula for this entry (same as TTreeFormula::GetNdata())
  • Iteration$ : return the current iteration over this formula for this entry (i.e. varies from 0 to Length$).
  • Length$(formula) : return the total number of element of the formula given as a parameter.
  • Sum$(formula) : return the sum of the value of the elements of the formula given as a parameter. For example the mean for all the elements in one entry can be calculated with: Sum$(formula)/Length$(formula)

GRID tools


  • svn co svn+ssh:// package
  • svn co svn+ssh:// trunk

To update or commit:
svn update [files]
svn commit [files] -m 'comments'

Other useful SVN commands:
  • to setup our group svn: export SVNROOT=svn+ssh://
  • to get a package: svn co $SVNROOT/< Package > Package
  • to update: svn update
  • to commit changes: svn commit [] -m "< description >"
  • svn info (info about files)
  • svn log --limit 3 (last 3 log entries)
  • svn status -u (shows if file is out-of-date w.r.t. repsoitory with * in 8th column)
  • svn resolve --accept working sandwich.txt (After manual edit of file to resolve conflict by hand using working copy)
  • svn propset svn:keywords "Date Author Rev" (then add fixed width tags $Rev:: $ )
  • svn propedit svn:ignore . (then add filenames and wildcard patterns to list of files to ignore for directory ".")
  • svn log -v -r HEAD:BASE (shows log entries between your base version and the head version. -v option is verbose = shows which files changed)
  • svnadmin create RepositoryName (cd to directory where you want the repo first!)
  • svnadmin dump /path/to/repository > repository-name.dmp (export entire repository to a file)
  • svnadmin load --force-uuid repository-name< repository-name.dmp (import entire repository from a file)
  • svnadmin recover /path/to/repository (makes repository self-consistent again - use if you get errors)
  • svn diff --diff-cmd /usr/bin/diff -x "-B -b" (use your own diff command and pass args into it)
  • svn status -v -N (list each files status and which revision it was last modified, do not recurse into subdirs (-N) )

SVN Twiki:


  • (lxplus) export PATH=/afs/$PATH
  • spell-check: ispell -d british -t file.tex
Edit | Attach | Watch | Print version | History: r19 | r16 < r15 < r14 < r13 | Backlinks | Raw View | Raw edit | More topic actions...
Topic revision: r14 - 2016-05-24 - AlexeyBoldyrev
    • Cern Search Icon Cern Search
    • TWiki Search Icon TWiki Search
    • Google Search Icon Google Search

    Main All webs login

This site is powered by the TWiki collaboration platform Powered by PerlCopyright & 2008-2020 by the contributing authors. All material on this collaboration platform is the property of the contributing authors.
or Ideas, requests, problems regarding TWiki? use Discourse or Send feedback