File indexing completed on 2025-01-18 09:14:58
0001
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012
0013
0014
0015
0016
0017
0018
0019
0020
0021
0022
0023
0024
0025
0026
0027
0028 #include "PersistencySetup.h"
0029 #include "DD4hep/Factories.h"
0030 #include "TFile.h"
0031
0032 using namespace std;
0033 using namespace dd4hep;
0034 using namespace PersistencyExamples;
0035
0036
0037
0038
0039
0040
0041
0042
0043
0044 static int persistency_example (Detector& , int argc, char** argv) {
0045 string input;
0046 bool arg_error = false;
0047 for(int i=0; i<argc && argv[i]; ++i) {
0048 if ( 0 == ::strncmp("-input",argv[i],4) )
0049 input = argv[++i];
0050 else
0051 arg_error = true;
0052 }
0053 if ( arg_error || input.empty() ) {
0054
0055 cout <<
0056 "Usage: -plugin <name> -arg [-arg] \n"
0057 " name: factory name DD4hep_PersistencyExample_read_cond \n"
0058 " -input <string> Geometry input file \n"
0059 " -iovs <number> Number of parallel IOV slots for processing. \n"
0060 "\tArguments given: " << arguments(argc,argv) << endl << flush;
0061 ::exit(EINVAL);
0062 }
0063
0064 PersistencyIO io;
0065 TFile*f = TFile::Open(input.c_str());
0066 f->ls();
0067 std::vector<dd4hep::Condition>* p = (std::vector<dd4hep::Condition>*)f->Get("Conditions");
0068 if ( p ) {
0069 int result = 0;
0070 for( const auto& cond : *p ) {
0071
0072 result += printCondition(cond);
0073 }
0074 printout(ALWAYS,"Example","+++ Read successfully %ld conditions. Result=%d",p->size(),result);
0075 }
0076 else {
0077 printout(ERROR,"Example","+++ ERROR +++ Failed to read object 'Conditions' from %s",f->GetName());
0078 }
0079
0080 return 1;
0081 }
0082
0083
0084 DECLARE_APPLY(DD4hep_PersistencyExample_read_cond,persistency_example)