File indexing completed on 2025-01-30 09:17:49
0001
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012
0013
0014 #include "ConditionAnyExampleObjects.h"
0015 #include "DD4hep/Factories.h"
0016
0017 using namespace std;
0018 using namespace dd4hep;
0019 using namespace dd4hep::ConditionExamples;
0020
0021
0022
0023
0024
0025
0026
0027
0028
0029 static int condition_example (Detector& description, int argc, char** argv) {
0030
0031 string input;
0032 PrintLevel print_level = INFO;
0033 int num_iov = 10, extend = 0;
0034 bool arg_error = false;
0035 for(int i=0; i<argc && argv[i]; ++i) {
0036 if ( 0 == ::strncmp("-input",argv[i],4) )
0037 input = argv[++i];
0038 else if ( 0 == ::strncmp("-iovs",argv[i],4) )
0039 num_iov = ::atol(argv[++i]);
0040 else if ( 0 == ::strncmp("-extend",argv[i],4) )
0041 extend = ::atol(argv[++i]);
0042 else if ( 0 == ::strncmp("-print",argv[i],4) )
0043 print_level = dd4hep::decodePrintLevel(argv[++i]);
0044 else
0045 arg_error = true;
0046 }
0047 if ( arg_error || input.empty() ) {
0048
0049 cout <<
0050 "Usage: -plugin <name> -arg [-arg] \n"
0051 " name: factory name DD4hep_ConditionExample_populate \n"
0052 " -input <string> Geometry file \n"
0053 " -iovs <number> Number of parallel IOV slots for processing. \n"
0054 " -print <leve> Set print level (number or string) \n"
0055 "\tArguments given: " << arguments(argc,argv) << endl << flush;
0056 ::exit(EINVAL);
0057 }
0058
0059
0060 description.fromXML(input);
0061
0062 detail::have_condition_item_inventory(1);
0063
0064
0065 ConditionsManager manager = installManager(description);
0066 const IOVType* iov_typ = manager.registerIOVType(0,"run").second;
0067 if ( 0 == iov_typ ) {
0068 except("ConditionsPrepare","++ Unknown IOV type supplied.");
0069 }
0070
0071 shared_ptr<ConditionsContent> content(new ConditionsContent());
0072 shared_ptr<ConditionsSlice> slice(new ConditionsSlice(manager,content));
0073 Scanner(ConditionsAnyKeys(*content,INFO),description.world());
0074 Scanner(ConditionsAnyDependencyCreator(*content,DEBUG,false,extend),description.world());
0075
0076
0077
0078 for(int i=0; i<num_iov; ++i) {
0079 IOV iov(iov_typ, IOV::Key(1+i*10,(i+1)*10));
0080 ConditionsPool* iov_pool = manager.registerIOV(*iov.iovType, iov.key());
0081
0082 Scanner(ConditionsAnyCreator(*slice, *iov_pool, print_level),description.world(),0,true);
0083 }
0084
0085
0086 ConditionsManager::Result total;
0087 for(int i=0; i<num_iov; ++i) {
0088 IOV req_iov(iov_typ,i*10+5);
0089
0090 ConditionsManager::Result r = manager.prepare(req_iov,*slice);
0091 total += r;
0092 if ( 0 == i ) {
0093 Scanner(ConditionsAnyDataAccess(req_iov, *slice, print_level), description.world());
0094 }
0095
0096 printout(ALWAYS,"Prepare","+ Total %ld conditions (S:%ld,L:%ld,C:%ld,M:%ld) of IOV %s",
0097 r.total(), r.selected, r.loaded, r.computed, r.missing, req_iov.str().c_str());
0098 }
0099 printout(ALWAYS,"Statistics","+=========================================================================");
0100 printout(ALWAYS,"Statistics","+ Accessed a total of %ld conditions (S:%6ld,L:%6ld,C:%6ld,M:%ld)",
0101 total.total(), total.selected, total.loaded, total.computed, total.missing);
0102 printout(ALWAYS,"Statistics","+=========================================================================");
0103
0104 return 1;
0105 }
0106
0107
0108 DECLARE_APPLY(DD4hep_ConditionAnyExample_populate,condition_example)