diff --git a/DDCore/include/DD4hep/AlignmentsPrinter.h b/DDCore/include/DD4hep/AlignmentsPrinter.h index e3149a0ba28eeb08907d4a20f79fbd78b6cc6833..49a6e578d488a2403cdcdf5478c08e4686a38142 100644 --- a/DDCore/include/DD4hep/AlignmentsPrinter.h +++ b/DDCore/include/DD4hep/AlignmentsPrinter.h @@ -35,7 +35,7 @@ namespace DD4hep { * \date 31/03/2016 * \ingroup DD4HEP_DDDB */ - class AlignmentsPrinter /* : public Alignment::Processor , public DetElement::Processor */ { + class AlignmentsPrinter { public: /// Conditionsmap to resolve things ConditionsMap* mapping; @@ -64,8 +64,6 @@ namespace DD4hep { virtual int operator()(DetElement de, int level) const; /// Callback to output alignments information virtual int operator()(Alignment alignment) const; - /// Processing callback to print alignments of a detector element - //virtual int processElement(DetElement de) override; }; @@ -81,18 +79,6 @@ namespace DD4hep { * \ingroup DD4HEP_DDDB */ class AlignedVolumePrinter : public AlignmentsPrinter { -#if 0 - public: - /// Printer name. Want to know who is printing what - std::string name; - /// Printout prefix - std::string prefix; - /// Printout level - PrintLevel printLevel; - protected: - /// Printout processing and customization flag - int m_flag; -#endif public: /// No default constructor AlignedVolumePrinter() = delete; @@ -100,17 +86,11 @@ namespace DD4hep { AlignedVolumePrinter(ConditionsMap* map, const std::string& prefix="",int flags=0); /// Default destructor virtual ~AlignedVolumePrinter() = default; - /// Set name for printouts - //void setName(const std::string& value) { name = value; } - /// Set prefix for printouts - //void setPrefix(const std::string& value) { prefix = value; } /// Callback to output alignments information of an entire DetElement virtual int operator()(DetElement de, int level) const override { return this->AlignmentsPrinter::operator()(de,level); } /// Callback to output alignments information virtual int operator()(Alignment cond) const override; - /// Callback to output alignments information of an entire DetElement - //virtual int processElement(DetElement de) override; }; /// Default printout of an alignment entry diff --git a/examples/AlignDet/CMakeLists.txt b/examples/AlignDet/CMakeLists.txt index 72a1a3df09330ae7bc986e7275464e78294057e1..ca177f76245bed2e32659a0f4f5329361ff1464d 100644 --- a/examples/AlignDet/CMakeLists.txt +++ b/examples/AlignDet/CMakeLists.txt @@ -105,6 +105,15 @@ dd4hep_add_test_reg( AlignDet_Telescope_align_new REGEX_FAIL " ERROR ;EXCEPTION;Exception" ) # +#---Testing: Load Telescope geometry and read and print alignments -------- +dd4hep_add_test_reg( AlignDet_Telescope_align_nominal + COMMAND "${CMAKE_INSTALL_PREFIX}/bin/run_test_AlignDet.sh" + EXEC_ARGS geoPluginRun -volmgr -destroy -plugin DD4hep_AlignmentExample_nominal + -input file:${DD4hep_DIR}/examples/AlignDet/compact/Telescope.xml + REGEX_PASS "Printed 20, scanned 20 and computed a total of 20 alignments \\(C:20,M:0\\)" + REGEX_FAIL " ERROR ;EXCEPTION;Exception" + ) +# #---Testing: Extended stress: Load CLICSiD geometry and have multiple runs on IOVs dd4hep_add_test_reg( AlignDet_CLICSiD_stress_LONGTEST COMMAND "${CMAKE_INSTALL_PREFIX}/bin/run_test_AlignDet.sh" @@ -114,6 +123,15 @@ dd4hep_add_test_reg( AlignDet_CLICSiD_stress_LONGTEST REGEX_FAIL " ERROR ;EXCEPTION;Exception" ) # +#---Testing: Load Telescope geometry and read and print alignments -------- +dd4hep_add_test_reg( AlignDet_CLICSiD_align_nominal + COMMAND "${CMAKE_INSTALL_PREFIX}/bin/run_test_AlignDet.sh" + EXEC_ARGS geoPluginRun -volmgr -destroy -plugin DD4hep_AlignmentExample_nominal + -input file:${DD4hep_DIR}/examples/CLICSiD/compact/compact.xml + REGEX_PASS "Printed 35011, scanned 35011 and computed a total of 35011 alignments \\(C:35011,M:0\\)" + REGEX_FAIL " ERROR ;EXCEPTION;Exception" + ) +# #---Testing: Load ALEPH TPC geometry -------------------------------------- dd4hep_add_test_reg( AlignDet_AlephTPC_load COMMAND "${CMAKE_INSTALL_PREFIX}/bin/run_test_AlignDet.sh" diff --git a/examples/AlignDet/src/AlignmentExampleObjects.h b/examples/AlignDet/src/AlignmentExampleObjects.h index 70689150c83a1eb7d828687d65c7d86f39463ee2..8bbae379e90a88a517ee701bbbbfa55378c2302a 100644 --- a/examples/AlignDet/src/AlignmentExampleObjects.h +++ b/examples/AlignDet/src/AlignmentExampleObjects.h @@ -49,6 +49,7 @@ namespace DD4hep { using Alignments::Delta; using Alignments::Alignment; using Alignments::AlignmentData; + using Alignments::AlignmentsPrinter; using Alignments::AlignmentsCalculator; using Alignments::AlignedVolumePrinter; using Alignments::DeltaCollector; diff --git a/examples/AlignDet/src/AlignmentExample_nominal.cpp b/examples/AlignDet/src/AlignmentExample_nominal.cpp index 1874f05ae100509cc971da66ad1c077a43e4adfb..52da70aa40e0b651046c6b4c128ea3a0ab2a19cd 100644 --- a/examples/AlignDet/src/AlignmentExample_nominal.cpp +++ b/examples/AlignDet/src/AlignmentExample_nominal.cpp @@ -19,8 +19,14 @@ geoPluginRun -volmgr -destroy -plugin DD4hep_AlignmentExample_nominal \ -input file:${DD4hep_DIR}/examples/AlignDet/compact/Telescope.xml - Access the DetElement nominal conditions using the AlignmentNominalMap + Access the DetElement nominal conditions using the AlignmentNominalMap. + Any use of DDCond is inhibited. + 1) We use the generic printer, which during the detector element scan accesses the + conditions map. + 2) We use a delta scanner to extract the nominal deltas from the DetElement's + nominal alignments + 3) We use a ConditionsTreeMap to perform the alignments re-computation. */ // Framework include files #include "AlignmentExampleObjects.h" @@ -43,21 +49,21 @@ static int alignment_example (Geometry::LCDD& lcdd, int argc, char** argv) { class Collector { public: AlignmentsCalculator::Deltas& deltas; - Collector(AlignmentsCalculator::Deltas& d) : deltas(d) {} + ConditionsMap& mapping; + Collector(AlignmentsCalculator::Deltas& d, ConditionsMap& m) + : deltas(d), mapping(m) {} + // Here we test the ConditionsMap interface of the AlignmentsNominalMap int operator()(DetElement de, int ) const { - Alignment a = de.nominal(); + Alignment a = mapping.get(de, Alignments::Keys::alignmentKey); deltas.insert(make_pair(de,a.delta())); return 1; } }; string input; - int num_iov = 10; bool arg_error = false; for(int i=0; i<argc && argv[i]; ++i) { if ( 0 == ::strncmp("-input",argv[i],4) ) input = argv[++i]; - else if ( 0 == ::strncmp("-iovs",argv[i],4) ) - num_iov = ::atol(argv[++i]); else arg_error = true; } @@ -67,7 +73,6 @@ static int alignment_example (Geometry::LCDD& lcdd, int argc, char** argv) { "Usage: -plugin <name> -arg [-arg] \n" " name: factory name DD4hep_AlignmentExample1 \n" " -input <string> Geometry file \n" - " -iovs <number> Number of parallel IOV slots for processing. \n" "\tArguments given: " << arguments(argc,argv) << endl << flush; ::exit(EINVAL); } @@ -75,50 +80,31 @@ static int alignment_example (Geometry::LCDD& lcdd, int argc, char** argv) { // First we load the geometry lcdd.fromXML(input); - /******************** Initialize the conditions manager *****************/ - ConditionsManager manager = installManager(lcdd); - const IOVType* iov_typ = manager.registerIOVType(0,"run").second; - if ( 0 == iov_typ ) - except("ConditionsPrepare","++ Unknown IOV type supplied."); - - /******************** Now as usual: create the slice ********************/ - shared_ptr<ConditionsContent> content(new ConditionsContent()); - shared_ptr<ConditionsSlice> slice(new ConditionsSlice(manager,content)); - shared_ptr<ConditionsMap> nominal(new Conditions::AlignmentsNominalMap(lcdd.world())); + // ++++++++++++++++++++++++ Try scam with the fake AlignmentsNominalMap + Conditions::AlignmentsNominalMap nominal(lcdd.world()); + // Collect all the delta conditions and make proper alignment conditions out of them AlignmentsCalculator::Deltas deltas; - Scanner(Collector(deltas),lcdd.world()); - printout(INFO,"Prepare","Got a total of %ld Deltas",deltas.size()); + // Show that the access interface works: + int num_delta = Scanner().scan(Collector(deltas,nominal),lcdd.world()); + /// Show that utilities can work with this one: + int num_printed = Scanner().scan(AlignmentsPrinter(&nominal),lcdd.world()); + printout(INFO,"Prepare","Got a total of %ld Deltas (Nominals: %d , Printed: %d)", + deltas.size(), num_delta, num_printed); - // ++++++++++++++++++++++++ Now compute the alignments for each of these IOVs - ConditionsManager::Result cond_total; - AlignmentsCalculator::Result align_total; - for(int i=0; i<num_iov; ++i) { - IOV req_iov(iov_typ,i*10+5); - shared_ptr<ConditionsSlice> sl(new ConditionsSlice(manager,content)); - // Attach the proper set of conditions to the user pool - ConditionsManager::Result cres = manager.prepare(req_iov,*sl); - sl->pool->flags |= Conditions::UserPool::PRINT_INSERT; - cond_total += cres; - // Now compute the tranformation matrices - AlignmentsCalculator calculator; - AlignmentsCalculator::Result ares = calculator.compute(deltas,*sl); - printout(INFO,"Prepare","Total %ld/%ld conditions (S:%ld,L:%ld,C:%ld,M:%ld) of type %s. Alignments:(C:%ld,M:%ld)", - slice->conditions().size(), cres.total(), cres.selected, cres.loaded, - cres.computed, cres.missing, iov_typ->str().c_str(), ares.computed, ares.missing); - align_total += ares; - if ( ares.missing > 0 ) { - printout(ERROR,"Compute","Failed tro compute %ld alignments of type %s.", - ares.missing, iov_typ->str().c_str()); - } + // ++++++++++++++++++++++++ Now compute the alignments for a generic slice + Conditions::ConditionsTreeMap slice; + // Now compute the tranformation matrices + AlignmentsCalculator calculator; + AlignmentsCalculator::Result ares = calculator.compute(deltas,slice); + printout(INFO,"Compute","Total %ld conditions inserted. Alignments:(C:%ld,M:%ld)", + slice.data.size(), ares.computed, ares.missing); + if ( ares.missing > 0 ) { + printout(ERROR,"Compute","Failed tro compute %ld alignments.",ares.missing); } - // What else ? let's access/print the current selection - Scanner(AlignedVolumePrinter(slice.get(),"Example"),lcdd.world()); - printout(INFO,"Summary","Processed a total %ld conditions (S:%ld,L:%ld,C:%ld,M:%ld) and (C:%ld,M:%ld) alignments.", - cond_total.total(), cond_total.selected, cond_total.loaded, cond_total.computed, cond_total.missing, - align_total.computed, align_total.missing); - + printout(INFO,"Summary","Printed %d, scanned %d and computed a total of %ld alignments (C:%ld,M:%ld).", + num_printed, num_delta, slice.data.size(), ares.computed, ares.missing); // All done. return 1; }