Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-01-30 09:17:44

0001 //==========================================================================
0002 //  AIDA Detector description implementation 
0003 //--------------------------------------------------------------------------
0004 // Copyright (C) Organisation europeenne pour la Recherche nucleaire (CERN)
0005 // All rights reserved.
0006 //
0007 // For the licensing terms see $DD4hepINSTALL/LICENSE.
0008 // For the list of contributors see $DD4hepINSTALL/doc/CREDITS.
0009 //
0010 // Author     : M.Frank
0011 //
0012 //==========================================================================
0013 /* 
0014  Plugin invocation:
0015  ==================
0016  This plugin behaves like a main program.
0017  Invoke the plugin with something like this:
0018 
0019  geoPluginRun -volmgr -destroy -plugin DD4hep_AlignmentExample_read_xml \
0020               -input file:${DD4hep_DIR}/examples/AlignDet/compact/Telescope.xml \
0021               -delta file:${DD4hep_DIR}/examples/Conditions/data/repository.xml 
0022 
0023 */
0024 // Framework include files
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 /// Plugin function: Alignment program example
0033 /**
0034  *  Factory: DD4hep_AlignmentExample_read_xml
0035  *
0036  *  \author  M.Frank
0037  *  \version 1.0
0038  *  \date    01/12/2016
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     /// Help printout describing the basic command line interface
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   // First we load the geometry
0064   description.fromXML(input);
0065 
0066   ConditionsManager manager  = installManager(description);
0067   const void*  delta_args[] = {delta.c_str(), 0}; // Better zero-terminate
0068 
0069   description.apply("DD4hep_ConditionsXMLRepositoryParser",1,(char**)delta_args);
0070   // Now the deltas are stored in the conditions manager in the proper IOV pools
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);      // IOV goes from run 1000 ... 2000
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   // ++++++++++++++++++++++++ Compute the tranformation matrices
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   // What else ? let's access the data
0094   size_t total_accessed = Scanner().scan(AlignmentDataAccess(*slice),description.world());
0095 
0096   // What else ? let's print the current selection
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   // ++++++++++++++++++++++++ All done.
0107   return 1;
0108 }
0109 
0110 // first argument is the type from the xml file
0111 DECLARE_APPLY(DD4hep_AlignmentExample_read_xml,alignment_example)