ATLAS Offline Software
Functions
reader.cxx File Reference
#include <stdlib.h>
#include <iostream>
#include "TChain.h"
#include "TFile.h"
#include "TTree.h"
#include "TrigInDetAnalysis/TIDAEvent.h"
#include "utils.h"
Include dependency graph for reader.cxx:

Go to the source code of this file.

Functions

int usage (std::ostream &s, int argc, char **argv)
 
int main (int argc, char **argv)
 

Detailed Description

Author
mark sutton
Date
Mon 30 Jan 2012 18:43:21 CET

Copyright (C) 2002-2023 CERN for the benefit of the ATLAS collaboration

Definition in file reader.cxx.

Function Documentation

◆ main()

int main ( int  argc,
char **  argv 
)

TChain* data = new TChain("tree"); opening each with a TTree is faster than a chain

Definition at line 43 of file reader.cxx.

43  {
44 
45  bool show_release = false;
46  bool quit_after_release = false;
47 
48  std::vector<std::string> files;
49 
50  if ( argc<2 ) {
51  // std::cerr << "usage: reader [-v] <filename>" << std::endl;
52  usage( std::cerr, argc, argv );
53  exit(-1);
54  }
55  else {
56  for ( int i=1 ; i<argc ; i++ ) {
57  std::string argi = std::string(argv[i]);
58  if ( argi == "-r" || argi == "--release" ) show_release = true;
59  if ( argi == "-ro" || argi == "--releaseonly" ) show_release = quit_after_release = true;
60  else if ( argi == "-h" || argi == "--help" ) return usage( std::cout, argc, argv );
61  else files.push_back( argi );
62  }
63  }
64 
65 
66  for ( unsigned i=0 ; i<files.size() ; i++ ) {
67 
68  TFile* finput = TFile::Open( files[i].c_str() );
69 
70  if ( finput==0 || !finput->IsOpen() || finput->IsZombie() ) {
71  std::cerr << "Error: could not open output file" << std::endl;
72  exit(-1);
73  }
74 
75  if ( show_release || quit_after_release ) {
76  TTree* dataTree = (TTree*)finput->Get("dataTree");
77  TString* releaseData = new TString("");
78 
79  if ( dataTree ) {
80  dataTree->SetBranchAddress( "ReleaseMetaData", &releaseData);
81 
82  for (unsigned int i=0; i<dataTree->GetEntries() ; i++ ) {
83  dataTree->GetEntry(i);
84  std::cout << "releaseData: " << *releaseData << std::endl;
85  }
86  }
87  else {
88  std::cerr << "no release data" << std::endl;
89  }
90  if ( quit_after_release ) return 0;
91  }
92 
93 
96  TTree* data = (TTree*)finput->Get("tree");
97 
98  TIDA::Event* track_ev = new TIDA::Event();
99  data->SetBranchAddress("TIDA::Event",&track_ev);
100  // data->AddFile( argv[i] );
101 
102  for (unsigned int i=0; i<data->GetEntries() ; i++ ) {
103  data->GetEntry(i);
104  std::cout << *track_ev << std::endl;
105  }
106 
107  finput->Close();
108 
109  }
110 
111  return 0;
112 }

◆ usage()

int usage ( std::ostream &  s,
int  argc,
char **  argv 
)

Definition at line 25 of file reader.cxx.

25  {
26  if ( argc>0 ) {
27  s << "Usage: " << argv[0] << " [OPTIONS] [-r] <input1.root input2.root ...>\n\n";
28  s << "Configuration: \n";
29  s << "Options: \n";
30  s << " -r, --release \t show the release data\n";
31  s << " -ro, --releaseonly \t show the release data and then quit\n";
32  s << " -h, --help \t this help\n";
33  // s << "\nReport bugs to <" << PACKAGE_BUGREPORT << ">";
34  s << std::endl;
35  }
36  return 0;
37 }
data
char data[hepevt_bytes_allocation_ATLAS]
Definition: HepEvt.cxx:11
python.SystemOfUnits.s
int s
Definition: SystemOfUnits.py:131
usage
int usage(std::ostream &s, int argc, char **argv)
Definition: reader.cxx:25
JiveXML::Event
struct Event_t Event
Definition: ONCRPCServer.h:65
TIDA::Event
Definition: TIDAEvent.h:33
lumiFormat.i
int i
Definition: lumiFormat.py:85
LArCellNtuple.argv
argv
Definition: LArCellNtuple.py:152
generateReferenceFile.files
files
Definition: generateReferenceFile.py:12
DQHistogramMergeRegExp.argc
argc
Definition: DQHistogramMergeRegExp.py:20
calibdata.exit
exit
Definition: calibdata.py:236