File indexing completed on 2025-01-30 09:17:49
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
0029 #include "ConditionExampleObjects.h"
0030 #include "DDCond/ConditionsIOVPool.h"
0031 #include "DDCond/ConditionsManager.h"
0032 #include "DDCond/ConditionsDataLoader.h"
0033 #include "DDCond/ConditionsRootPersistency.h"
0034 #include "DD4hep/Factories.h"
0035
0036 using namespace std;
0037 using namespace dd4hep;
0038 using namespace dd4hep::ConditionExamples;
0039
0040 static void help(int argc, char** argv) {
0041
0042 cout <<
0043 "Usage: -plugin <name> -arg [-arg] \n"
0044 " name: factory name DD4hep_ConditionExample_manual_load \n"
0045 " -input <string> Geometry file \n"
0046 " -conditions <string> Conditions input file \n"
0047 " -runs <number> Number of parallel IOV slots for processing. \n"
0048 "\tArguments given: " << arguments(argc,argv) << endl << flush;
0049 ::exit(EINVAL);
0050 }
0051
0052
0053
0054
0055
0056
0057
0058
0059
0060 static int condition_example (Detector& description, int argc, char** argv) {
0061 string input, conditions;
0062 int num_runs = 10;
0063 bool arg_error = false;
0064 for(int i=0; i<argc && argv[i]; ++i) {
0065 if ( 0 == ::strncmp("-input",argv[i],4) )
0066 input = argv[++i];
0067 else if ( 0 == ::strncmp("-conditions",argv[i],4) )
0068 conditions = argv[++i];
0069 else if ( 0 == ::strncmp("-runs",argv[i],4) )
0070 num_runs = ::atol(argv[++i]);
0071 else
0072 arg_error = true;
0073 }
0074 if ( arg_error || input.empty() || conditions.empty() ) help(argc,argv);
0075
0076
0077 description.fromXML(input);
0078
0079
0080 description.apply("DD4hep_ConditionsManagerInstaller",0,(char**)0);
0081
0082 ConditionsManager manager = ConditionsManager::from(description);
0083 manager["PoolType"] = "DD4hep_ConditionsLinearPool";
0084 manager["UserPoolType"] = "DD4hep_ConditionsMapUserPool";
0085 manager["UpdatePoolType"] = "DD4hep_ConditionsLinearUpdatePool";
0086 manager["LoaderType"] = "DD4hep_Conditions_root_Loader";
0087 manager.initialize();
0088
0089 printout(ALWAYS,"Example","Load conditions data from file:%s",conditions.c_str());
0090 manager.loader().addSource(conditions);
0091
0092
0093 shared_ptr<ConditionsContent> content(new ConditionsContent());
0094 shared_ptr<ConditionsSlice> slice(new ConditionsSlice(manager,content));
0095
0096
0097
0098
0099 Scanner(ConditionsKeys(*content,INFO),description.world());
0100
0101
0102
0103
0104 Scanner(ConditionsDependencyCreator(*content,DEBUG),description.world());
0105
0106
0107 const IOVType* iov_typ = manager.iovType("run");
0108 ConditionsManager::Result total;
0109 for ( int irun=0; irun < num_runs; ++irun ) {
0110 IOV req_iov(iov_typ,irun*10+5);
0111
0112
0113 ConditionsManager::Result r = manager.prepare(req_iov,*slice);
0114 total += r;
0115 if ( 0 == irun ) {
0116
0117
0118 Scanner(ConditionsPrinter(slice.get(),"Example"),description.world());
0119 }
0120
0121 printout(ALWAYS,"Prepare","Total %ld conditions (S:%ld,L:%ld,C:%ld,M:%ld) of IOV %s",
0122 r.total(), r.selected, r.loaded, r.computed, r.missing, req_iov.str().c_str());
0123 }
0124 printout(ALWAYS,"Statistics","+=========================================================================");
0125 printout(ALWAYS,"Statistics","+ Accessed a total of %ld conditions (S:%6ld,L:%6ld,C:%6ld,M:%ld)",
0126 total.total(), total.selected, total.loaded, total.computed, total.missing);
0127 printout(ALWAYS,"Statistics","+=========================================================================");
0128
0129 return 1;
0130 }
0131
0132
0133 DECLARE_APPLY(DD4hep_ConditionExample_manual_load,condition_example)