BOSS 8.0.0
BESIII Offline Software System
Loading...
Searching...
No Matches
calibCoverage.cxx File Reference
#include "Coverage.h"
#include "calibUtil/Metadata.h"
#include <cstdio>
#include <iostream>
#include "string.h"

Go to the source code of this file.

Namespaces

namespace  rdbModel

Functions

void printHelp ()
int main (int argc, char *argv[])

Function Documentation

◆ main()

int main ( int argc,
char * argv[] )

Definition at line 48 of file calibCoverage.cxx.

48 {
49
52
53 if ( argc < 2 )
54 {
55 printHelp();
56 exit( 0 );
57 }
58
59 // rdbModel::MysqlConnection* conn = new rdbModel::MysqlConnection();
60 // First do read connection to db, see if xml schema is compatible with db
61 // Then use it to check other arguments
62 std::string dbname = "calib"; // the default
63 // Gives us whatever is in requirements for host and table
64 std::string defValue = "*";
65
66 if ( argc > 6 )
67 {
68 if ( ( argv[6] ) != "*" ) dbname = std::string( argv[6] );
69 }
70 Metadata* meta = new Metadata( defValue, defValue, dbname );
71
72 if ( !meta )
73 {
74 std::cerr << "Unable to construct calibUtil::Metadata object " << std::endl;
75 std::cerr.flush();
76 exit( 1 );
77 }
78 Metadata::eRet ret;
79 bool ok = meta->connectRead( ret );
80
81 if ( !ok )
82 {
83 std::cerr << "Connection to metadata dbs failed with return code " << ret << std::endl;
84 std::cerr.flush();
85 exit( 1 );
86 }
87 rdbModel::Rdb* rdb = meta->getRdb();
88
89 std::string instr( "LAT" );
90 std::string flavor( "vanilla" );
91 std::string level( "PROD" );
92
93 Timestamp ts;
94 // Sort out instr, flavor, level, ts arguments. Update local
95 // variables if values other than defaults supplied
96 if ( argc > 2 )
97 {
98 if ( !strcmp( argv[2], "*" ) ) instr = std::string( argv[2] );
99 if ( argc > 3 )
100 {
101 if ( !strcmp( argv[3], "*" ) ) flavor = std::string( argv[3] );
102 if ( argc > 4 )
103 {
104 if ( !strcmp( argv[4], "*" ) ) level = std::string( argv[4] );
105 }
106 }
107 }
108 if ( argc > 5 )
109 {
110 try
111 { ts = Timestamp( std::string( argv[5] ) ); } catch ( facilities::BadTimeInput ex )
112 {
113 std::cerr << "Caught facilities::BadTimeInput exception with complaint " << ex.complaint
114 << std::endl
115 << "Exiting..." << std::endl;
116 std::cerr.flush();
117 exit( 1 );
118 }
119 }
120 else ts = Timestamp( 0, 0 );
121
122 // Check instrument, level against standard list;
123 // put out warning (but don't exit) if not found
124 if ( rdb )
125 {
128 cols.reserve( 2 );
129 vals.reserve( 2 );
130
131 cols.push_back( std::string( "instrument" ) );
132 vals.push_back( instr );
133 cols.push_back( std::string( "proc_level" ) );
134 vals.push_back( level );
135 if ( !( meta->checkValues( cols, vals ) ) )
136 {
137 std::cout << "Non-standard value for instrument or level. " << std::endl;
138 std::cout << "Supplied values were " << instr << ", " << level << ", respectively."
139 << std::endl;
140 }
141 }
142
143 Coverage cov( meta, instr, flavor, level, ts );
144 // If calibtype arg is a class, generate list
145
146 std::vector<std::string> calibTypes;
147
148 // Following fails only if arg was a calibration class (TKR, CAL or *
149 // meaning "all" and we don't have a schema.
150 // ..except for now we haven't implemented classes at all.
151 std::string arg1( argv[1] );
152 bool expanded = cov.expandTypes( arg1, calibTypes );
153 if ( !expanded ) { exit( 1 ); }
154 // For each calibtype, do the work
155 for ( unsigned i = 0; i < calibTypes.size(); i++ )
156 {
157 unsigned ret = cov.checkType( calibTypes[i] );
158 if ( ret > 0 )
159 {
160 std::cerr << "Type " << calibTypes[i] << " failed with return code " << ret << std::endl;
161 }
162 else { std::cout << "Type " << calibTypes[i] << " ok in metadata database " << std::endl; }
163 }
164 return 0;
165}
double meta
void printHelp()

◆ printHelp()

void printHelp ( )
@file calibCoverage

Determine whether, for a given calibration type (or set of calibration types), instrument, flavor, proc_level there is precisely one matching calibration in db. In all cases, supplying * for an argument will give you the default value for it

Call with arguments

calibtype    Specific type, e.g. "TKR_splits", or class.  Allowable
             classes are "CAL", "TKR", and "*"   (all).
instrument   Defaults to LAT
flavor       Defaults to "vanilla"
level        (i.e., proc_level) defaults to "PROD"
start        Timestamp for beginning of time period to be covered.
             Defaults to vstart for first calibration found
db           Defaults to "calib" (production db)

For most of the work, see Coverage class

Definition at line 32 of file calibCoverage.cxx.

32 {
33 std::cout << "Invoke as follows: " << std::endl;
34 std::cout << "calibCoverage calibtype instrument flavor level start db" << std::endl;
35 std::cout << "All arguments but the first are optional. Defaults are: " << std::endl;
36 std::cout << "instrument = 'LAT'" << std::endl;
37 std::cout << "flavor = 'vanilla'" << std::endl;
38 std::cout << "level = 'PROD'" << std::endl;
39 std::cout << "start = '1970-1-1 00:00'" << std::endl;
40 std::cout << "db = 'calib'" << std::endl;
41}

Referenced by main().