- Timestamp:
- 11/12/17 20:02:22 (7 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/FACT++/src/rootifysql.cc
r18927 r18929 1 1 #include "Database.h" 2 3 #include <regex> 2 4 3 5 #include "Time.h" … … 26 28 ("compression,c", var<uint16_t>(1), "zlib compression level for the root file") 27 29 ("tree,t", var<string>("Result"), "Name of the root tree") 30 ("ignore", vars<string>(), "Ignore the given columns") 28 31 ("display,d", po_switch(), "Displays contents on the screen (most usefull in combination with mysql statements as SHOW or EXPLAIN)") 29 ("null,n", po_switch(), "Redirect the output file to /dev/null") 32 ("null,n", po_switch(), "Redirect the output file to /dev/null (mainly for debugging purposes, e.g. performance studies)") 33 ("no-fill", po_switch(), "Do not fill events into the root file (mainly for debugging purposes, e.g. performance studies)") 30 34 ("delimiter", var<string>(""), "The delimiter used if contents are displayed with --display (default=\\t)") 31 35 ("verbose,v", var<uint16_t>(1), "Verbosity (0: quiet, 1: default, 2: more, 3, ...)") … … 64 68 "filename is specified by the --file option or a query is given with --query.\n" 65 69 "\n" 70 "As a trick, the rootify.sql file can be made excutable (chmod u+x rootify.sql). " 71 "If the first line contains '#!rootifysql', the script can be executed directly.\n" 72 "\n" 66 73 "Comments in the query-file can be placed according to the SQL standard inline " 67 "/*comment*/ or on individual lines introduces with # or --.\n"74 "/*comment*/ or introduced with # (shell script style) or -- (SQL style).\n" 68 75 "\n" 69 76 "In case of succes, 0 is returned, a value>0 otherwise.\n" … … 94 101 const string tree = conf.Get<string>("tree"); 95 102 const bool force = conf.Get<bool>("force"); 96 const bool ignore 103 const bool ignorenull = conf.Get<bool>("ignore-null"); 97 104 const bool update = conf.Get<bool>("update"); 98 105 const bool display = conf.Get<bool>("display"); 99 106 const bool noout = conf.Get<bool>("null"); 107 const bool nofill = conf.Get<bool>("no-fill"); 100 108 const uint16_t verbose = conf.Get<uint16_t>("verbose"); 101 109 const uint16_t compression = conf.Get<uint16_t>("compression"); 102 110 const string delimiter = conf.Get<string>("delimiter"); 111 const vector<string> ignore = conf.Vec<string>("ignore"); 103 112 // ------------------------------------------------------------------------- 104 113 … … 202 211 203 212 vector<double> buf(l.size()); 204 vector<uint8_t> typ(l.size(),'n'); 213 vector<uint8_t> typ(l.size(),'n'); // n=number [double], d is used for DateTime 205 214 206 215 UInt_t cols = 0; 216 207 217 208 218 // -------------------- Configure branches of TTree ------------------------ 209 219 TTree *ttree = new TTree(tree.c_str(), query.c_str()); 220 221 size_t skipat = 0; 222 size_t skipreg = 0; 210 223 for (size_t i=0; i<l.size(); i++) 211 224 { … … 227 240 typ[i] = 'C'; 228 241 229 const bool use = typ[i]!='V' && typ[i]!='C'; 242 bool found = false; 243 for (const auto &pattern: ignore) 244 { 245 if (regex_match(l[i], regex(pattern))) 246 { 247 found = true; 248 typ[i] = '-'; 249 skipreg++; 250 break; 251 } 252 } 253 254 if (l[i][0]=='@') 255 { 256 typ[i] = '@'; 257 skipat++; 258 } 259 260 const bool use = l[i][0]!='@' && typ[i]!='V' && typ[i]!='C' && !found; 230 261 231 262 if (verbose>1) … … 243 274 cout << endl; 244 275 if (verbose>0) 276 { 277 if (skipreg) 278 cout << skipreg << " branches skipped due to ignore list." << endl; 279 if (skipat) 280 cout << skipat << " branches skipped due to name starting with @." << endl; 245 281 cout << "Configured " << cols << " branches.\nFilling branches..." << endl; 282 } 246 283 247 284 if (display) … … 273 310 } 274 311 275 if (!ignore && col->is_null())312 if (!ignorenull && col->is_null()) 276 313 { 277 314 skip++; … … 295 332 case 'V': 296 333 case 'C': 334 case '-': 335 case '@': 297 336 break; 298 337 … … 304 343 if (idx==row.size()) 305 344 { 306 ttree->Fill(); 345 if (!nofill) 346 ttree->Fill(); 347 307 348 if (display) 308 349 cout << sout.str() << endl; … … 310 351 311 352 row = res.fetch_row(); 353 312 354 313 355 } while (row);
Note:
See TracChangeset
for help on using the changeset viewer.