File indexing completed on 2025-01-30 09:17:44
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 "AlignmentExampleObjects.h"
0028 #include "DD4hep/Factories.h"
0029
0030 using namespace std;
0031 using namespace dd4hep;
0032 using namespace dd4hep::AlignmentExamples;
0033
0034
0035
0036
0037
0038
0039
0040
0041
0042 static int alignment_example (Detector& description, int argc, char** argv) {
0043
0044 string input;
0045 int num_iov = 10;
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 if ( 0 == ::strncmp("-iovs",argv[i],4) )
0051 num_iov = ::atol(argv[++i]);
0052 else
0053 arg_error = true;
0054 }
0055 if ( arg_error || input.empty() ) {
0056
0057 cout <<
0058 "Usage: -plugin <name> -arg [-arg] \n"
0059 " name: factory name DD4hep_AlignmentExample1 \n"
0060 " -input <string> Geometry file \n"
0061 " -iovs <number> Number of parallel IOV slots for processing. \n"
0062 "\tArguments given: " << arguments(argc,argv) << endl << flush;
0063 ::exit(EINVAL);
0064 }
0065
0066
0067 description.fromXML(input);
0068
0069
0070 ConditionsManager manager = installManager(description);
0071 const IOVType* iov_typ = manager.registerIOVType(0,"run").second;
0072 if ( 0 == iov_typ )
0073 except("ConditionsPrepare","++ Unknown IOV type supplied.");
0074
0075
0076
0077 size_t total_created = 0;
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 total_created += Scanner().scan(AlignmentCreator(manager, *iov_pool),description.world());
0083 }
0084
0085
0086 shared_ptr<ConditionsContent> content(new ConditionsContent());
0087 shared_ptr<ConditionsSlice> slice(new ConditionsSlice(manager,content));
0088 cond::fill_content(manager,*content,*iov_typ);
0089
0090
0091
0092
0093
0094
0095
0096 IOV iov(iov_typ,10+5);
0097 manager.prepare(iov,*slice);
0098 slice->pool->flags |= cond::UserPool::PRINT_INSERT;
0099
0100
0101 map<DetElement, Delta> deltas;
0102 Scanner(deltaCollector(*slice,deltas),description.world());
0103 printout(INFO,"Prepare","Got a total of %ld Deltas",deltas.size());
0104
0105
0106 ConditionsManager::Result cond_total;
0107 AlignmentsCalculator::Result align_total;
0108 for(int i=0; i<num_iov; ++i) {
0109 IOV req_iov(iov_typ,i*10+5);
0110 shared_ptr<ConditionsSlice> sl(new ConditionsSlice(manager,content));
0111
0112 ConditionsManager::Result cres = manager.prepare(req_iov,*sl);
0113 sl->pool->flags |= cond::UserPool::PRINT_INSERT;
0114 cond_total += cres;
0115
0116 AlignmentsCalculator calculator;
0117 AlignmentsCalculator::Result ares = calculator.compute(deltas,*sl);
0118 printout(INFO,"Prepare","Total %ld/%ld conditions (S:%ld,L:%ld,C:%ld,M:%ld) of type %s. Alignments:(C:%ld,M:%ld)",
0119 slice->conditions().size(), cres.total(), cres.selected, cres.loaded,
0120 cres.computed, cres.missing, iov_typ->str().c_str(), ares.computed, ares.missing);
0121 align_total += ares;
0122 if ( ares.missing > 0 ) {
0123 printout(ERROR,"Compute","Failed tro compute %ld alignments of type %s.",
0124 ares.missing, iov_typ->str().c_str());
0125 }
0126 if ( i == 0 ) {
0127
0128 Scanner(AlignedVolumePrinter(sl.get(),"Example"),description.world());
0129 }
0130 }
0131 printout(INFO,"Summary","Processed a total %ld conditions (S:%ld,L:%ld,C:%ld,M:%ld) and (C:%ld,M:%ld) alignments. Created:%ld.",
0132 cond_total.total(), cond_total.selected, cond_total.loaded, cond_total.computed, cond_total.missing,
0133 align_total.computed, align_total.missing, total_created);
0134
0135
0136 return 1;
0137 }
0138
0139
0140 DECLARE_APPLY(DD4hep_AlignmentExample_populate,alignment_example)