-- LimingChen - 10-Oct-2010

ROOT skill

ROOT versions

root setup from atlasLocalSetup

#2012.04.23
export ATLAS_LOCAL_ROOT_BASE=/cvmfs/atlas.cern.ch/repo/ATLASLocalRootBase
source ${ATLAS_LOCAL_ROOT_BASE}/user/atlasLocalSetup.sh
localSetupROOT

root version from athena

  • how to see ROOT version on athena release. Example /afs/cern.ch/atlas/software/releases/16.3.0/sw/lcg/app/releases/ROOT/.
  • set up root from athena
export AtlasSetup=/afs/cern.ch/atlas/software/releases/16.6.0/AtlasSetup
alias asetup='source $AtlasSetup/scripts/asetup.sh'
asetup 16.6.0

root version from lxplus

Case 1:

Generally this works well.
#/bin/sh
echo "root 5.28 running on slc5, i686-slc5-gcc43-opt, bash"
export ROOTSYS=/afs/cern.ch/sw/lcg/app/releases/ROOT/5.28.00/i686-slc5-gcc43-opt/root
export PATH=$ROOTSYS/bin:$PATH
export LD_LIBRARY_PATH=$ROOTSYS/lib:$LD_LIBRARY_PATH
# Liming CHEN 2011-2-22
# From Zhichao Zhan 

Case 2:

Sometimes this is not good for you, and lead some errors, like:
===========open root file
dlopen error: /usr/lib64/libstdc++.so.6: version `GLIBCXX_3.4.9' not found (required by /afs/cern.ch/sw/lcg/app/releases/ROOT/5.26.00e_python2.6/x86_64-slc5-gcc43-dbg/root/lib/libNetx.so)
Load Error: Failed to load Dynamic link library /afs/cern.ch/sw/lcg/app/releases/ROOT/5.26.00e_python2.6/x86_64-slc5-gcc43-dbg/root/lib/libNetx.so
Error in <TCint::AutoLoad>: failure loading library libNetx.so for class TXNetSystem
Error in <TPluginHandler::SetupCallEnv>: class TXNetSystem not found in plugin Netx
*** Interpreter error recovered ***
Error in <TPluginHandler::SetupCallEnv>: class TXNetFile not found in plugin Netx
===========display the root file
Error: illegal pointer to class object f1 0x0 74  (tmpfile):1:
*** Interpreter error recovered ***
===========get the keys in the file
Error: illegal pointer to class object f1 0x0 74  (tmpfile):1:
*** Interpreter error recovered ***

Case 3:

Please try to use this one. I recommend you to do this!
echo "root 5.26/00e running on slc5, bash"
source /afs/cern.ch/sw/lcg/contrib/gcc/4.3/x86_64-slc5-gcc43-opt/setup.sh
#export ROOTSYS=/afs/cern.ch/sw/lcg/app/releases/ROOT/5.26.00/x86_64-slc5-gcc43-opt/root
export ROOTSYS=/afs/cern.ch/sw/lcg/app/releases/ROOT/5.26.00e_python2.6/x86_64-slc5-gcc43-dbg/root
export PATH=/afs/cern.ch/sw/lcg/external/Python/2.5.4p2/x86_64-slc5-gcc43-opt/bin:$ROOTSYS/bin:${PATH}
export LD_LIBRARY_PATH=$ROOTSYS/lib:/afs/cern.ch/sw/lcg/external/Python/2.5.4p2/x86_64-slc5-gcc43-opt/lib:${LD_LIBRARY_PATH}
export PYTHONPATH=$PYTHONPATH:$ROOTSYS/lib
# From Li bo 2011-3-1

Case 4:

If you get errors like this run_cint_C.so: wrong ELF class: ELFCLASS32 The problem is a 32/64 bit conflict.

Last case:

  • source /afs/cern.ch/atlas/software/releases/16.0.2/gcc-alt-432/i686-slc5-gcc43-opt/setup.sh to seup the athena in bash
  • echo $CMTCONFIG to see which cmtconfig is
  • cat /proc/version hope it is help for you.

Root Error

  • 1. Error message
Error: Symbol #include is not defined in current scope  (tmpfile):1:
Error: Symbol exception is not defined in current scope  (tmpfile):1:
Syntax Error: #include <exception> (tmpfile):1:
Error: Symbol G__exception is not defined in current scope  (tmpfile):1:
Error: type G__exception not defined FILE:(tmpfile) LINE:1
*** Interpreter error recovered ***

Reason and Solution: Memory leakage problem. When the leakage is getting big enough it produces this error. In the case pointer is defined and memory is allocated but didn't deleted after using.

  • 2. "[ROOT] Load Error: Failed to load Dynamic link library"
 This usually happens when the compiler version used to build ROOT is not the
same as the compiler available in the path (i.e. bash> g++ -v).

Root code

THistPainter

http://root.cern.ch/root/html/THistPainter.html

Sumw2() and TH1::SetDefaultSumw2 (1)

Take care of the posistion of Sumw2() and TH1::SetDefaultSumw2 (1)
{
  TH1::SetDefaultSumw2(true);

  TH1F* h = new TH1F("testName", "title", 2, 0, 2);

  //h->Sumw2();

  h->Fill(1.2, 1);
  h->Fill(1.5, 1);
  h->Fill(1.7, 1);
  h->Fill(1.7, -1);

  h->Fill(0.7, -1);
  h->Fill(0.5, 1);

  cout<<"bin1 = "<<h->GetBinContent(1)<<"  "<<h->GetBinError(1)<<endl;
  cout<<"bin2 = "<<h->GetBinContent(2)<<"  "<<h->GetBinError(2)<<endl;

  TH1F* h2 = (TH1F*) h->Clone("htest");

  cout<<"bin1 = "<<h2->GetBinContent(1)<<"  "<<h2->GetBinError(1)<<endl;
  cout<<"bin2 = "<<h2->GetBinContent(2)<<"  "<<h2->GetBinError(2)<<endl;
}

Histogram bin error effect mean error

{
  gROOT->Reset();
  
  TH1F* h1 = new TH1F("name1", "title1", 4, -1.5, 1.5);
  TH1F* h2 = new TH1F("name2", "title2", 4, -1.5, 1.5);

  h1->SetBinContent(1, 2);
  h1->SetBinContent(2, 2);
  h1->SetBinContent(3, 4);
  h1->SetBinContent(4, 4);

  h2->SetBinContent(1, 2);
  h2->SetBinContent(2, 2);
  h2->SetBinContent(3, 4);
  h2->SetBinContent(4, 4);

  h2->SetBinError(1, 1);
  h2->SetBinError(2, 1);
  h2->SetBinError(3, 1);
  h2->SetBinError(4, 1);

  cout<<"h1 mean "<<h1->GetMean()<<" +/- "<<h1->GetMeanError()<<endl;
  cout<<"h2 mean "<<h2->GetMean()<<" +/- "<<h2->GetMeanError()<<endl;
}

h1 mean 0.25 +/- 0.231053
h2 mean 0.25 +/- 0.133398

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")

Print root variables to txt file

void EventRunNember(){

  TString sourcefile="normal.root";
  TFile *f = TFile::Open(sourcefile);
  TTree* t = (TTree*)f->Get("Myphysics");
  cout<<" source root file is :"<<sourcefile<<endl;

  int EventNumber;
  bool lim_AfterRec_TTbar;
  vector<double> *f_CalZ0;
  t->SetBranchAddress("EventNumber",        &EventNumber);
  t->SetBranchAddress("lim_AfterRec_TTbar", &lim_AfterRec_TTbar);
  t->SetBranchAddress("TruZ0", &f_TruZ0);

  int entries = t->GetEntriesFast();
  ofstream DilepEvt("DilepEvt.txt");

  TDatime sDate;
  DilepEvt<<"Program start at "<<sDate.GetDate()<<" :: "<<sDate.GetTime()<<endl<<endl;

  for (int i=0; i<entries; i++){
    t->GetEntry(i);
    if (!lim_AfterRec_TTbar) continue;
    DilepEvt<<EventNumber<<endl;
  }

  TDatime eDate;
  DilepEvt<<"Program end at "<<eDate.GetDate()<<" :: "<<eDate.GetTime()<<endl<<endl;
}

Make and Load pakage under root macro

    gSystem->Exec("cd KLFitterD3PD;  make");
    //gSystem->Exec("cp -f KLFitterD3PD/libKLFitter.so .");
    //gSystem->Load("libKLFitter.so");
    gSystem->Load("KLFitterD3PD/libKLFitter.so");
    cout<<" load libKLFitter"<<endl;
    gROOT->ProcessLine(".L candidate.C+");
    gROOT->ProcessLine(".L checkOQ.C+");
    gROOT->ProcessLine(".L physicsD3PD.C+");

Read more than one root file

  std::string argStr1 = argv[1];
  std::vector<std::string> fileList;
  for (size_t i=0,n; i <= argStr1.length(); i=n+1) {
    n = argStr1.find_first_of(',',i);
    if (n == std::string::npos) n = argStr1.length();
    std::string tmp = argStr1.substr(i,n-i);
    fileList.push_back(tmp);
  }

  std::string argStr2 = argv[2] ;
  const char* ntupleName = argStr2.c_str() ;

  TChain* c2a = new TChain( ntupleName );
  for (unsigned int iFile=0; iFile<fileList.size(); ++iFile) {
     std::cout << "-> adding " << fileList[iFile] << "..." << std::endl;
     c2a->Add(fileList[iFile].c_str());
  }

Add branch to one tree

  void tree() {

  TFile *oldFile = TFile::Open("/tmp/lchen/user.dta.105200.T1_McAtNlo_Jimmy.PDF.e835_s1272_s1274_r3043_r2993_p937.mc11c.v5/test_PDF_NTUP_TOP.758242._000159.root.1.pdfdat.all.root", "READ");
  TTree* cteqTree = (TTree*) oldFile->Get("cteq66_LHgridweight");
  cteqTree->SetBranchStatus("*", 1);

  TFile *newFile = new TFile("newTree.root", "recreate");
  TTree *newTree = cteqTree->CloneTree(0);
  newTree->CopyEntries(cteqTree);

  float testV;
  TBranch *newBranch = newTree->Branch("testV", &testV, "testV/F");

  testV = 2.;
  int entries = cteqTree->GetEntries();
  for (int i=0; i<entries; i++)
  {
    testV = 2.;
    newBranch->Fill();
  }

  //newTree->Print();
  newFile->Write();
  delete oldFile;
  delete newFile;
}

print txt file

txt format "\tab" or " "
37  0.98337 1.03378 1.06389
120 0.988417    1.01329 1.00575
259 0.974786    1.02658 1.00876
294 0.985581    1.03193 1.09154
424 0.986205    1.0169  1.00218
446 0.984606    1.03272 1.09208
515 0.985429    1.03131 1.08949
582 0.965955    1.04966 0.985003
605 1.02249 0.971731    1.04445
628 0.983319    1.03818 1.09095
660 0.983431    1.0371  1.09327
1483    0.973145    1.03081 0.999313
1539    0.985533    1.03266 1.09252

{
  int EvtNum=0;
  double pdfW1(0.), pdfW2(0.), pdfW3(0.);
  ifstream fin ("matchEvents.txt");
  while (fin >> EvtNum >> pdfW1 >> pdfW2 >> pdfW3) {
    cout<<EvtNum<<"  "<<pdfW1<<"  "<<pdfW2<<"  "<<pdfW3<<endl;
  }
}

PRoof Skill

AtlasProofWG

Goals:

  • Document the current usage in Atlas in Tier 2 and Tier 3 sites.
    • This does not need to be an exhaustive survey.
  • Evaluation of the Proof PQ2 tools for Tier 3 data management
  • Provide alpha version of disk management tools (disk server drain, files rearrangement)
  • Develop suggestion for deployment at all Tier 3 sites.
  • PROOF tools to locate files (and other metadata) across the local facilities
  • Use of PROOF for local analysis (single and multi-user usage)
  • Propose test metrics for the considered design and tabulate the results

Leaders:

Members:

Back Up

PRoof Skill: This is a backup web.
Edit | Attach | Watch | Print version | History: r20 < r19 < r18 < r17 < r16 | Backlinks | Raw View | WYSIWYG | More topic actions
Topic revision: r20 - 2013-01-17 - unknown
 
    • 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-2019 by the contributing authors. All material on this collaboration platform is the property of the contributing authors.
Ideas, requests, problems regarding TWiki? Send feedback