Back to home page

EIC code displayed by LXR

 
 

    


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

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_ConditionExample_populate \
0020    -input file:${DD4hep_DIR}/examples/AlignDet/compact/Telescope.xml
0021 
0022    Populate the conditions store by hand for a set of IOVs.
0023    Then compute the corresponding alignment entries....
0024 
0025 */
0026 // Framework include files
0027 #include "ConditionExampleObjects.h"
0028 #include "DD4hep/Factories.h"
0029 
0030 using namespace std;
0031 using namespace dd4hep;
0032 using namespace dd4hep::ConditionExamples;
0033 
0034 /// Plugin function: Condition program example
0035 /**
0036  *  Factory: DD4hep_ConditionExample_populate
0037  *
0038  *  \author  M.Frank
0039  *  \version 1.0
0040  *  \date    01/12/2016
0041  */
0042 static int condition_example (Detector& description, int argc, char** argv)  {
0043 
0044   string     input;
0045   PrintLevel print_level = INFO;
0046   int        num_iov = 10, extend = 0;
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 if ( 0 == ::strncmp("-extend",argv[i],4) )
0054       extend = ::atol(argv[++i]);
0055     else if ( 0 == ::strncmp("-print",argv[i],4) )
0056       print_level = dd4hep::decodePrintLevel(argv[++i]);
0057     else
0058       arg_error = true;
0059   }
0060   if ( arg_error || input.empty() )   {
0061     /// Help printout describing the basic command line interface
0062     cout <<
0063       "Usage: -plugin <name> -arg [-arg]                                             \n"
0064       "     name:   factory name     DD4hep_ConditionExample_populate                \n"
0065       "     -input   <string>        Geometry file                                   \n"
0066       "     -iovs    <number>        Number of parallel IOV slots for processing.    \n"
0067       "     -print   <leve>          Set print level (number or string)              \n"
0068       "\tArguments given: " << arguments(argc,argv) << endl << flush;
0069     ::exit(EINVAL);
0070   }
0071 
0072   // First we load the geometry
0073   description.fromXML(input);
0074 
0075   detail::have_condition_item_inventory(1);
0076   
0077   /******************** Initialize the conditions manager *****************/
0078   ConditionsManager manager = installManager(description);
0079   const IOVType*    iov_typ = manager.registerIOVType(0,"run").second;
0080   if ( 0 == iov_typ )
0081     except("ConditionsPrepare","++ Unknown IOV type supplied.");
0082 
0083   /******************** Now as usual: create the slice ********************/
0084   shared_ptr<ConditionsContent> content(new ConditionsContent());
0085   shared_ptr<ConditionsSlice>   slice(new ConditionsSlice(manager,content));
0086   Scanner(ConditionsKeys(*content,INFO),description.world());
0087   Scanner(ConditionsDependencyCreator(*content,DEBUG,false,extend),description.world());
0088 
0089   /******************** Populate the conditions store *********************/
0090   // Have 10 run-slices [11,20] .... [91,100]
0091   for(int i=0; i<num_iov; ++i)  {
0092     IOV iov(iov_typ, IOV::Key(1+i*10,(i+1)*10));
0093     ConditionsPool*   iov_pool = manager.registerIOV(*iov.iovType, iov.key());
0094     // Create conditions with all deltas. Use a generic creator
0095     Scanner(ConditionsCreator(*slice, *iov_pool, print_level),description.world(),0,true);
0096   }
0097   
0098   // ++++++++++++++++++++++++ Now compute the conditions for each of these IOVs
0099   ConditionsManager::Result total;
0100   for(int i=0; i<num_iov; ++i)  {
0101     IOV req_iov(iov_typ,i*10+5);
0102     // Select the proper set of conditions and attach them to the user pool
0103     ConditionsManager::Result r = manager.prepare(req_iov,*slice);
0104     total += r;
0105     if ( 0 == i )  { // First one we print...
0106       Scanner(ConditionsPrinter(slice.get(),"Example"),description.world());
0107     }
0108     // Now compute the tranformation matrices
0109     printout(ALWAYS,"Prepare","Total %ld conditions (S:%ld,L:%ld,C:%ld,M:%ld) of IOV %s",
0110              r.total(), r.selected, r.loaded, r.computed, r.missing, req_iov.str().c_str());
0111   }  
0112   printout(ALWAYS,"Statistics","+=========================================================================");
0113   printout(ALWAYS,"Statistics","+  Accessed a total of %ld conditions (S:%6ld,L:%6ld,C:%6ld,M:%ld)",
0114            total.total(), total.selected, total.loaded, total.computed, total.missing);
0115   printout(ALWAYS,"Statistics","+=========================================================================");
0116   // All done.
0117   return 1;
0118 }
0119 
0120 // first argument is the type from the xml file
0121 DECLARE_APPLY(DD4hep_ConditionExample_populate,condition_example)