Warning, file /DD4hep/examples/Conditions/src/ConditionExample_populate.cpp was not indexed
or was modified since last indexation (in which case cross-reference links may be missing, inaccurate or erroneous).
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 #include "ConditionExampleObjects.h"
0028 #include "DD4hep/Factories.h"
0029
0030 using namespace std;
0031 using namespace dd4hep;
0032 using namespace dd4hep::ConditionExamples;
0033
0034
0035
0036
0037
0038
0039
0040
0041
0042 static int condition_example (Detector& description, int argc, char** argv) {
0043
0044 string input;
0045 PrintLevel print_level = INFO;
0046 int num_iov = 10, extend = 0;
0047 bool arg_error = false;
0048 for(int i=0; i<argc && argv[i]; ++i) {
0049 if ( 0 == ::strncmp("-input",argv[i],4) )
0050 input = argv[++i];
0051 else if ( 0 == ::strncmp("-iovs",argv[i],4) )
0052 num_iov = ::atol(argv[++i]);
0053 else if ( 0 == ::strncmp("-extend",argv[i],4) )
0054 extend = ::atol(argv[++i]);
0055 else if ( 0 == ::strncmp("-print",argv[i],4) )
0056 print_level = dd4hep::decodePrintLevel(argv[++i]);
0057 else
0058 arg_error = true;
0059 }
0060 if ( arg_error || input.empty() ) {
0061
0062 cout <<
0063 "Usage: -plugin <name> -arg [-arg] \n"
0064 " name: factory name DD4hep_ConditionExample_populate \n"
0065 " -input <string> Geometry file \n"
0066 " -iovs <number> Number of parallel IOV slots for processing. \n"
0067 " -print <leve> Set print level (number or string) \n"
0068 "\tArguments given: " << arguments(argc,argv) << endl << flush;
0069 ::exit(EINVAL);
0070 }
0071
0072
0073 description.fromXML(input);
0074
0075 detail::have_condition_item_inventory(1);
0076
0077
0078 ConditionsManager manager = installManager(description);
0079 const IOVType* iov_typ = manager.registerIOVType(0,"run").second;
0080 if ( 0 == iov_typ )
0081 except("ConditionsPrepare","++ Unknown IOV type supplied.");
0082
0083
0084 shared_ptr<ConditionsContent> content(new ConditionsContent());
0085 shared_ptr<ConditionsSlice> slice(new ConditionsSlice(manager,content));
0086 Scanner(ConditionsKeys(*content,INFO),description.world());
0087 Scanner(ConditionsDependencyCreator(*content,DEBUG,false,extend),description.world());
0088
0089
0090
0091 for(int i=0; i<num_iov; ++i) {
0092 IOV iov(iov_typ, IOV::Key(1+i*10,(i+1)*10));
0093 ConditionsPool* iov_pool = manager.registerIOV(*iov.iovType, iov.key());
0094
0095 Scanner(ConditionsCreator(*slice, *iov_pool, print_level),description.world(),0,true);
0096 }
0097
0098
0099 ConditionsManager::Result total;
0100 for(int i=0; i<num_iov; ++i) {
0101 IOV req_iov(iov_typ,i*10+5);
0102
0103 ConditionsManager::Result r = manager.prepare(req_iov,*slice);
0104 total += r;
0105 if ( 0 == i ) {
0106 Scanner(ConditionsPrinter(slice.get(),"Example"),description.world());
0107 }
0108
0109 printout(ALWAYS,"Prepare","Total %ld conditions (S:%ld,L:%ld,C:%ld,M:%ld) of IOV %s",
0110 r.total(), r.selected, r.loaded, r.computed, r.missing, req_iov.str().c_str());
0111 }
0112 printout(ALWAYS,"Statistics","+=========================================================================");
0113 printout(ALWAYS,"Statistics","+ Accessed a total of %ld conditions (S:%6ld,L:%6ld,C:%6ld,M:%ld)",
0114 total.total(), total.selected, total.loaded, total.computed, total.missing);
0115 printout(ALWAYS,"Statistics","+=========================================================================");
0116
0117 return 1;
0118 }
0119
0120
0121 DECLARE_APPLY(DD4hep_ConditionExample_populate,condition_example)