Page Menu
Home
HEPForge
Search
Configure Global Search
Log In
Files
F11221550
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Flag For Later
Size
5 KB
Subscribers
None
View Options
Index: trunk/src/tableInspector.cpp
===================================================================
--- trunk/src/tableInspector.cpp (revision 231)
+++ trunk/src/tableInspector.cpp (revision 232)
@@ -1,157 +1,158 @@
//==============================================================================
// tableInspector.cpp
//
// Copyright (C) 2010-2016 Tobias Toll and Thomas Ullrich
//
// This file is part of Sartre.
//
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation.
// This program is distributed in the hope that it will be useful,
// but without any warranty; without even the implied warranty of
// merchantability or fitness for a particular purpose. See the
// GNU General Public License for more details.
// You should have received a copy of the GNU General Public License
// along with this program. If not, see <http://www.gnu.org/licenses/>.
//
// Author: Thomas Ullrich
// Last update:
// $Date$
// $Author$
//==============================================================================
//
// Utility program to check the integrity of lookup tables used in Sartre.
// Usage: tableInspector [-x bin -y bin -z bin | -g bin | [-a] [-s] [-b]] file(s) ...
// -b print table id in binary representation first
// -a print position and values of each cell
// -s print statstics of table content (min, max, empty bines etc.)
// -g bin returns the ROOT/table bins in x,y,z for a given global bin
// -x bin -y bin -z bin
// returns the global bin for a given set of ROOT/table bins
//==============================================================================
#include "Table.h"
#include <iostream>
#include <unistd.h>
#include <cstdlib>
#include <string>
+#include <unistd.h>
using namespace std;
template<class T> string binary(T word)
{
int nbits = 8*sizeof(T);
string bitpattern(nbits+1, ' ');
unsigned long long mask = 1;
mask <<= (nbits-1);
for (int i=0; i<nbits; i++) {
bitpattern[i] = (((word&mask) == mask) ? '1' : '0');
mask >>= 1;
}
bitpattern[nbits] = '\0';
return bitpattern;
}
template<class T> void printBinary(T word)
{
string bits = binary(word);
cout << bits.c_str() << endl;
}
void usage(const char* prog)
{
cout << "Usage: " << prog << " [ -x bin -y bin -z bin | -g bin | [-a] [-s] [-b]] file(s) ..." << endl;
cout << " " << "-b print table id in binary representation first" << endl;
cout << " " << "-a print position and values of each cell" << endl;
cout << " " << "-s print statstics of table content (min, max, empty bines etc.)" << endl;
cout << " " << "-g bin returns the ROOT/table bins in x,y,z for a given global bin" << endl;
cout << " " << "-x bin -y bin -z bin returns the global bin for a given set of ROOT/table bins" << endl;
}
int main(int argc, char **argv)
{
//
// Handle command line arguments
//
if (argc == 1) {
usage(argv[0]);
return 2;
}
bool listall = false;
bool liststat = false;
bool calcXYZ = false;
bool calcGlobal = false;
bool binaryId = false;
int globalBin = 0;
int binx = 1;
int biny = 1;
int binz = 1;
int ch;
while ((ch = getopt(argc, argv, "absg:x:y:z:")) != -1) {
switch (ch) {
case 'a':
listall = true;
break;
case 'b':
binaryId = true;
break;
case 's':
liststat = true;
break;
case 'g':
globalBin = atol(optarg);
calcXYZ = true;
break;
case 'x':
binx = atol(optarg);
calcGlobal = true;
break;
case 'y':
biny = atol(optarg);
calcGlobal = true;
break;
case 'z':
binz = atol(optarg);
calcGlobal = true;
break;
case '?':
default:
usage(argv[0]);
return 2;
break;
}
}
if (optind == argc || ( calcXYZ && calcGlobal ) || ( (calcXYZ || calcGlobal) && (listall || liststat) ) ) {
usage(argv[0]);
return 2;
}
//
// List table info (optionally list all entries)
//
for (int index = optind; index < argc; index++) {
Table tbl;
if (tbl.read(argv[index])) {
if (binaryId) {
uint64_t theId = tbl.id();
cout << "Table ID = ";
printBinary(theId);
}
if (calcXYZ) {
tbl.binXYZ(globalBin, binx, biny, binz);
cout << argv[index] << ": ";
cout << globalBin << " --> binx=" << binx << " (Q2), biny=" << biny << " (W2), binz=" << binz << " (t)" << endl;
}
else if (calcGlobal) {
globalBin = tbl.globalBin(binx, biny, binz);
cout << argv[index] << ": ";
cout << "binx=" << binx << " (Q2), biny=" << biny << " (W2), binz=" << binz << " (t) --> " << globalBin << endl;
}
else {
tbl.list(cout, listall, liststat);
}
}
}
return 0;
}
File Metadata
Details
Attached
Mime Type
text/x-diff
Expires
Wed, May 14, 10:33 AM (1 d, 11 h)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
5111182
Default Alt Text
(5 KB)
Attached To
rSARTRESVN sartresvn
Event Timeline
Log In to Comment