Project

General

Profile

STNTUPLE Wiki pages

STNTUPLE HowTO’s

How to check quickly the STNTUPLE contents

  • ... you are done with primer#1
  • ... and current directory is the top-most directory of your test release and you have STNTUPLE shared libraries built in ./lib/
  • here is what you do next:
root [1] TStnAna y("/mu2e/data/users/murat/datasets/e00s1412/e00s1412.0000010000");
root [2] y.PrintStat(100)
TStnRun2InputModule::BeginJob Warning - no metadata,
     opening all chained files to count entries...
Warning in <TClass::TClass>: no dictionary for class TStnTrack::InterData_t is available
TStnRun2InputModule::BeginJob: chained    1 files,      1000 events
Collection name='TObjArray', class='TObjArray', size=10
--------------------------------------------------------------------------------------------------------
........... branch name .....................<event size>  <sigma size>  TotBytes   ZipBytes CompFactor   % of File
--------------------------------------------------------------------------------------------------------
HeaderBlock                                           91       0         95900       7254  13.22        0.0
CalDataBlock                                      145622    4095     145464796   73944132   1.97       25.2
StrawDataBlock                                     65383    7422      67379609   40492963   1.66       13.8
TrackBlock                                           258     303        291585      99471   2.93        0.0
ClusterBlock                                       49868    4159      49839940   28568505   1.74        9.7
GenpBlock                                         842595    9977     843499812  150803721   5.59       51.3
SimpBlock                                            252       0        256880      65545   3.92        0.0
---------------------------------------------------------------------------------------------------
........... total .............. <event size> <sigma size> <disk size>
---------------------------------------------------------------------------------------------------
 total event                    1104069.480    15627.058   293248.770

root [3] TStnAna z("/mu2e/data/users/murat/datasets/e00s1442/e00s1442.0000010000");
root [4] z.PrintStat(100)
TStnRun2InputModule::BeginJob Warning - no metadata,
     opening all chained files to count entries...
TStnRun2InputModule::BeginJob: chained    1 files,     29678 events
Collection name='TObjArray', class='TObjArray', size=10
--------------------------------------------------------------------------------------------------------
........... branch name .....................<event size>  <sigma size>  TotBytes   ZipBytes CompFactor   % of File
--------------------------------------------------------------------------------------------------------
HeaderBlock                                           91       0       2823010     161936  17.43        0.5
CalDataBlock                                         426     143      12421944    4766930   2.61       13.4
StrawDataBlock                                      1457     964      47055428   20423480   2.30       57.3
TrackBlock                                           379     275      11299632    4493776   2.51       12.6
ClusterBlock                                         296     144       8641853    2438027   3.54        6.8
GenpBlock                                            232       0       7012456    1387873   5.05        3.9
SimpBlock                                            252       0       7606720    1964945   3.87        5.5
---------------------------------------------------------------------------------------------------
........... total .............. <event size> <sigma size> <disk size>
---------------------------------------------------------------------------------------------------
 total event                       3133.080     1226.664     1152.718

How to read a STNTUPLE and drop some of the data blocks

 //-----------------------------------------------------------------------------
 //  this script shows how to copy a few events from STNTUPLE file into
 //  another file and drop some data blocks(by default all the data blocks 
 //  are copied into the output file)
 //
 //  "dropped" data blocks are not read in, unless explicitly requested by
 //  one of the TStnModule's included into event loop. This allows to copy 
 //  ntuples with one (or more) branches corrupted
 //
 //  required code commited into repository on May 14 2002
 //  As no other STNTUPLE library depends on libStntuple_loop, you can check 
 //  it out from development and rebuild, leaving all the rest code unchanged:
 //
 //  cvs co -A Stntuple/loop
 //  cvs co -A Stntuple/Stntuple/loop
 //  setenv USESHLIBS 1
 //  make Stntuple._loop
 //-----------------------------------------------------------------------------
   TChain* chain = new TChain("STNTUPLE");
   chain->Add("/cdf/scratch/murat/etme01-138425-139339-s232.stn"); 

   TStnAna* x = new TStnAna(chain);

   TStnOutputModule* om;

   om = new TStnOutputModule("./results/junk.root");
   om->SetMaxFileSize(1000);
   om->DropDataBlock("PhotonBlock");
   om->DropDataBlock("MuonBlock");

   x->SetOutputModule(om);
   x->Run(100);
 }

How to print a dataset

The example script below shows how to create, print and use a Stntuple dataset

void primer_005(const char* Book    = "stntuple/dev_242",
                const char* Dataset = "sqcd00",
                const char* Fileset = "sqcd00.0000") {

  TStnAna*     x;
  TStnCatalog* ctl = new TStnCatalog();
  TStnDataset* ds  = new TStnDataset();

  ctl->InitDataset(ds,Book,Dataset,Fileset,"");
  ds->Print();
  x = new TStnAna(ds);
                               // ... run analysis loop on 100 events
  x->Run(100);
}

How to concatenate STNTUPLE’s

2014-07-24: update Stntuple (‘cvs co -r dev_420 -d Stntuple Offline/Stntuple’)

  1. step one: create concatenation requests. Needs ruby, so run on mu2egpvm*.fnal.gov
Stntuple/scripts/make_concat_requests.rb -i /mu2e/data/users/gianipez/datasets/cnvs0140 -o $PWD/results -p cnvs -b detsim -d cnvs0141 -f stntuple  -t $PWD/test.C
  1. step 2: run concatenator. This step needs some polishing, writes output to $PWD/results subdirectory

Stntuple/scripts/submit_concatenator -j stntuple -b detsim -d cnvs0141 -J 1:1 -o $PWD -i test.C -r $PWD -f local

How to Catalog STNTUPLE’s

Stntuple/scripts/catalog_stntuples -d cb0s0012 -D /mu2e/data/users/murat/datasets -p cb0s0012

‘-d’ : dataset name
‘-D’ : defines the directory name
‘-p’ : selects the filename pattern to grep on
X

need to run on mu2egp** (no ruby on detsim)
check the created AAA_CATALOG.html to make sure that the server name is correct
in .rootrc (home.fnal.gov points to FNALU):
Stntuple.Catalog http://home.fnal.gov/~murat/cafdfc

See comments inside the script for more details

How to use TStnAna directly

The event loop utility, TStnAna, can be accessed directly from the ROOT prompt:

root [2] g.x
(class TStnAna*)0x1ff0afb0

Direct access to TStnAna object allows to do the following interactively:

process next event:

    
root [2] g.x->Continue(1)

process next 100 events:

root [2] g.x->Continue(100)

process an event with given run/event numbers:

    
root [2] g.x->ProcessEvent(Run,Event)

process a given entry in the Chain:

    
root [2] g.x->ProcessEntry(101)

save histograms:

    
root [2] g.x->SaveHist(Filename)

More details

when stnana.C is loaded, an object of StnAnaGlobals_t type is created. This object is accessible under the name ‘g’.
‘g.x’ points to the Stntuple event loop utility, TStnAna:

root [6] .class StnAnaGlobals_t
===========================================================================
struct StnAnaGlobals_t
 size=0x140 FILE:Stntuple/scripts/global_vars.h LINE:7
 (tagnum=3846,voffset=-1,isabstract=0,parent=-1,gcomp=0:0,funcs(dn21=~xcpd)=0)
Defined in StnAnaGlobals_t
Stntuple/scripts/global_vars.h   8 0xffffffffffffffff TStnAna* x
Stntuple/scripts/global_vars.h   9 0x7        TString Task , size=24
Stntuple/scripts/global_vars.h  10 0x1f       TString JobName , size=24
Stntuple/scripts/global_vars.h  11 0x37       TString JobNumber , size=24
Stntuple/scripts/global_vars.h  12 0x4f       Int_t JobType //0:Run, 1:EventList
Stntuple/scripts/global_vars.h  13 0x53       Int_t DoMc //to be redefined in stnana
Stntuple/scripts/global_vars.h  14 0x57       TString CalibPass , size=24
Stntuple/scripts/global_vars.h  15 0x6f       TString GoodRunList , size=24
Stntuple/scripts/global_vars.h  16 0x87       Int_t MinRun
Stntuple/scripts/global_vars.h  17 0x8b       Int_t MaxRun
Stntuple/scripts/global_vars.h  18 0x8f       TEventList* EventList
Stntuple/scripts/global_vars.h  19 0x97       Int_t* RunEventList
Stntuple/scripts/global_vars.h  20 0x9f       TString L3TrigPath , size=24
Stntuple/scripts/global_vars.h  21 0xb7       Int_t DoLittle
Stntuple/scripts/global_vars.h  22 0xbf       TString LittleFileName , size=24
Stntuple/scripts/global_vars.h  23 0xd7       TString HistFileName , size=24
Stntuple/scripts/global_vars.h  24 0xef       TString OutputFileName , size=24
Stntuple/scripts/global_vars.h  25 0x107      Int_t Debug
Stntuple/scripts/global_vars.h  26 0x10b      Int_t IDMode
Stntuple/scripts/global_vars.h  27 0x10f      Int_t NEvents
Stntuple/scripts/global_vars.h  28 0x117      TObjArray* ListOfTasks
Stntuple/scripts/global_vars.h  31 0x11f      TChain* chain
Stntuple/scripts/global_vars.h  32 0x127      TStnCatalog* catalog
Stntuple/scripts/global_vars.h  33 0x12f      TStnDataset* dataset
Stntuple/scripts/global_vars.h  34 0x137      TStnGoodRunList* gGoodRunList

The structure is initialized upon a call to stnana(...). After the first call to stnana(...) one can access g.x interactively.