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 #include "AlignmentExampleObjects.h"
0026 #include "DD4hep/Factories.h"
0027
0028 using namespace std;
0029 using namespace dd4hep;
0030 using namespace dd4hep::AlignmentExamples;
0031
0032
0033
0034
0035
0036
0037
0038
0039
0040 static int alignment_example (Detector& description, int argc, char** argv) {
0041
0042 string input, delta;
0043 bool arg_error = false;
0044 for(int i=0; i<argc && argv[i]; ++i) {
0045 if ( 0 == ::strncmp("-input",argv[i],4) )
0046 input = argv[++i];
0047 else if ( 0 == ::strncmp("-deltas",argv[i],5) )
0048 delta = argv[++i];
0049 else
0050 arg_error = true;
0051 }
0052 if ( arg_error || input.empty() || delta.empty() ) {
0053
0054 cout <<
0055 "Usage: -plugin <name> -arg [-arg] \n"
0056 " name: factory name DD4hep_AlignmentExample_read_xml \n"
0057 " -input <string> Geometry file \n"
0058 " -deltas <string> Alignment deltas (Conditions \n"
0059 "\tArguments given: " << arguments(argc,argv) << endl << flush;
0060 ::exit(EINVAL);
0061 }
0062
0063
0064 description.fromXML(input);
0065
0066 ConditionsManager manager = installManager(description);
0067 const void* delta_args[] = {delta.c_str(), 0};
0068
0069 description.apply("DD4hep_ConditionsXMLRepositoryParser",1,(char**)delta_args);
0070
0071 const IOVType* iov_typ = manager.iovType("run");
0072 if ( 0 == iov_typ )
0073 except("ConditionsPrepare","++ Unknown IOV type supplied.");
0074
0075 IOV req_iov(iov_typ,1500);
0076 shared_ptr<ConditionsContent> content(new ConditionsContent());
0077 shared_ptr<ConditionsSlice> slice(new ConditionsSlice(manager,content));
0078 cond::fill_content(manager,*content,*iov_typ);
0079
0080 ConditionsManager::Result cres = manager.prepare(req_iov,*slice);
0081
0082 AlignmentsCalculator calc;
0083 ConditionsHashMap alignments;
0084
0085 map<DetElement, Delta> deltas;
0086 Scanner(deltaCollector(*slice, deltas),description.world());
0087 printout(INFO,"Prepare","Got a total of %ld Deltas",deltas.size());
0088
0089 slice->pool->flags |= cond::UserPool::PRINT_INSERT;
0090 AlignmentsCalculator::Result ares = calc.compute(deltas, alignments);
0091 ConditionsSlice::Inserter(*slice,alignments.data);
0092
0093
0094 size_t total_accessed = Scanner().scan(AlignmentDataAccess(*slice),description.world());
0095
0096
0097 Scanner(AlignedVolumePrinter(slice.get(),"Example"),description.world());
0098
0099 printout(INFO,"Example",
0100 "%ld conditions in slice. (T:%ld,S:%ld,L:%ld,C:%ld,M:%ld) "
0101 "Alignments accessed: %ld (A:%ld,M:%ld) for IOV:%-12s",
0102 slice->pool->size(),
0103 cres.total(), cres.selected, cres.loaded, cres.computed, cres.missing,
0104 total_accessed, ares.computed, ares.missing, iov_typ->str().c_str());
0105
0106
0107 return 1;
0108 }
0109
0110
0111 DECLARE_APPLY(DD4hep_AlignmentExample_read_xml,alignment_example)