Back to home page

EIC code displayed by LXR

 
 

    


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

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