File indexing completed on 2025-01-30 09:17:50
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 #include "TStatistic.h"
0030 #include "TTimeStamp.h"
0031
0032 using namespace std;
0033 using namespace dd4hep;
0034 using namespace dd4hep::ConditionExamples;
0035
0036
0037
0038
0039
0040
0041
0042
0043
0044 static int condition_example (Detector& description, int argc, char** argv) {
0045 string input;
0046 int num_iov = 10;
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
0054 arg_error = true;
0055 }
0056 if ( arg_error || input.empty() ) {
0057
0058 cout <<
0059 "Usage: -plugin <name> -arg [-arg] \n"
0060 " name: factory name DD4hep_ConditionExample_stress2 \n"
0061 " -input <string> Geometry file \n"
0062 " -iovs <number> Number of collision loads to be performed. \n"
0063 "\tArguments given: " << arguments(argc,argv) << endl << flush;
0064 ::exit(EINVAL);
0065 }
0066
0067
0068 description.fromXML(input);
0069
0070
0071 ConditionsManager manager = installManager(description);
0072 const IOVType* iov_typ = manager.registerIOVType(0,"run").second;
0073 if ( 0 == iov_typ )
0074 except("ConditionsPrepare","++ Unknown IOV type supplied.");
0075
0076
0077 shared_ptr<ConditionsContent> content(new ConditionsContent());
0078 shared_ptr<ConditionsSlice> slice(new ConditionsSlice(manager,content));
0079 Scanner(ConditionsKeys(*content,INFO),description.world());
0080 Scanner(ConditionsDependencyCreator(*content,DEBUG),description.world());
0081
0082 size_t total_created = 0;
0083 ConditionsManager::Result total;
0084 TStatistic cr_stat("Creation"), acc_stat("Access");
0085
0086 for(int i=0; i<num_iov; ++i) {
0087 {
0088 TTimeStamp start;
0089 IOV iov(iov_typ, IOV::Key(1+i*10,(i+1)*10));
0090 ConditionsPool* iov_pool = manager.registerIOV(*iov.iovType, iov.key());
0091
0092 int count = Scanner().scan(ConditionsCreator(*slice, *iov_pool, DEBUG),description.world());
0093 TTimeStamp stop;
0094 total_created += count;
0095 cr_stat.Fill(stop.AsDouble()-start.AsDouble());
0096 printout(INFO,"Creating", "Setup %-6ld conditions for IOV:%-60s [%8.3f sec]",
0097 count, iov.str().c_str(), stop.AsDouble()-start.AsDouble());
0098 } {
0099 TTimeStamp start;
0100 IOV req_iov(iov_typ,i*10+5);
0101
0102 ConditionsManager::Result res = manager.prepare(req_iov,*slice);
0103 TTimeStamp stop;
0104 total += res;
0105 acc_stat.Fill(stop.AsDouble()-start.AsDouble());
0106
0107 printout(INFO,"Compute","Total %-6ld conditions (S:%6ld,L:%6ld,C:%6ld,M:%4ld) of type %-25s [%8.3f sec]",
0108 res.total(), res.selected, res.loaded, res.computed, res.missing,
0109 req_iov.str().c_str(), stop.AsDouble()-start.AsDouble());
0110 }
0111 }
0112 printout(INFO,"Statistics","+======= Summary: # of IOV: %3d ===========================================", num_iov);
0113 printout(INFO,"Statistics","+ %-12s: %11.5g +- %11.4g RMS = %11.5g N = %lld",
0114 cr_stat.GetName(), cr_stat.GetMean(), cr_stat.GetMeanErr(), cr_stat.GetRMS(), cr_stat.GetN());
0115 printout(INFO,"Statistics","+ %-12s: %11.5g +- %11.4g RMS = %11.5g N = %lld",
0116 acc_stat.GetName(), acc_stat.GetMean(), acc_stat.GetMeanErr(), acc_stat.GetRMS(), acc_stat.GetN());
0117 printout(INFO,"Statistics","+ Accessed a total of %ld conditions (S:%6ld,L:%6ld,C:%6ld,M:%ld)",
0118 total.total(), total.selected, total.loaded, total.computed, total.missing, total_created);
0119 printout(INFO,"Statistics","+=========================================================================");
0120
0121 return 1;
0122 }
0123
0124
0125 DECLARE_APPLY(DD4hep_ConditionExample_stress2,condition_example)