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_AlignmentExample_stress \
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 #include "TStatistic.h"
0030 #include "TTimeStamp.h"
0031 
0032 using namespace std;
0033 using namespace dd4hep;
0034 using namespace dd4hep::ConditionExamples;
0035 
0036 /// Plugin function: Condition program example
0037 /**
0038  *  Factory: DD4hep_ConditionExample_stress2
0039  *
0040  *  \author  M.Frank
0041  *  \version 1.0
0042  *  \date    01/12/2016
0043  */
0044 static int condition_example (Detector& description, int argc, char** argv)  {
0045   string input;
0046   int    num_iov = 10;
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
0054       arg_error = true;
0055   }
0056   if ( arg_error || input.empty() )   {
0057     /// Help printout describing the basic command line interface
0058     cout <<
0059       "Usage: -plugin <name> -arg [-arg]                                             \n"
0060       "     name:   factory name     DD4hep_ConditionExample_stress2                 \n"
0061       "     -input   <string>        Geometry file                                   \n"
0062       "     -iovs    <number>        Number of collision loads to be performed.      \n"
0063       "\tArguments given: " << arguments(argc,argv) << endl << flush;
0064     ::exit(EINVAL);
0065   }
0066 
0067   // First we load the geometry
0068   description.fromXML(input);
0069 
0070   /******************** Initialize the conditions manager *****************/
0071   ConditionsManager manager = installManager(description);
0072   const IOVType*    iov_typ = manager.registerIOVType(0,"run").second;
0073   if ( 0 == iov_typ )
0074     except("ConditionsPrepare","++ Unknown IOV type supplied.");
0075 
0076   /******************** Now as usual: create the slice ********************/
0077   shared_ptr<ConditionsContent> content(new ConditionsContent());
0078   shared_ptr<ConditionsSlice> slice(new ConditionsSlice(manager,content));
0079   Scanner(ConditionsKeys(*content,INFO),description.world());
0080   Scanner(ConditionsDependencyCreator(*content,DEBUG),description.world());
0081 
0082   size_t total_created = 0;
0083   ConditionsManager::Result total;
0084   TStatistic cr_stat("Creation"), acc_stat("Access");
0085   // ++++++++++++++++++++++++ Now compute the conditions for each of these IOVs
0086   for(int i=0; i<num_iov; ++i)  {
0087     {
0088       TTimeStamp start;
0089       IOV iov(iov_typ, IOV::Key(1+i*10,(i+1)*10));
0090       ConditionsPool*   iov_pool = manager.registerIOV(*iov.iovType, iov.key());
0091       // Create conditions with all deltas. Use a generic creator
0092       int count = Scanner().scan(ConditionsCreator(*slice, *iov_pool, DEBUG),description.world());
0093       TTimeStamp stop;
0094       total_created += count;
0095       cr_stat.Fill(stop.AsDouble()-start.AsDouble());
0096       printout(INFO,"Creating", "Setup %-6ld conditions for IOV:%-60s  [%8.3f sec]",
0097                count, iov.str().c_str(), stop.AsDouble()-start.AsDouble());
0098     }   {
0099       TTimeStamp start;
0100       IOV req_iov(iov_typ,i*10+5);
0101       // Attach the proper set of conditions to the user pool
0102       ConditionsManager::Result res = manager.prepare(req_iov,*slice);
0103       TTimeStamp stop;
0104       total += res;
0105       acc_stat.Fill(stop.AsDouble()-start.AsDouble());
0106       // Now compute the tranformation matrices
0107       printout(INFO,"Compute","Total %-6ld conditions (S:%6ld,L:%6ld,C:%6ld,M:%4ld) of type %-25s [%8.3f sec]",
0108                res.total(), res.selected, res.loaded, res.computed, res.missing,
0109                req_iov.str().c_str(), stop.AsDouble()-start.AsDouble());
0110     }
0111   }
0112   printout(INFO,"Statistics","+======= Summary: # of IOV: %3d ===========================================", num_iov);
0113   printout(INFO,"Statistics","+  %-12s:  %11.5g +- %11.4g  RMS = %11.5g  N = %lld",
0114            cr_stat.GetName(), cr_stat.GetMean(), cr_stat.GetMeanErr(), cr_stat.GetRMS(), cr_stat.GetN());
0115   printout(INFO,"Statistics","+  %-12s:  %11.5g +- %11.4g  RMS = %11.5g  N = %lld",
0116            acc_stat.GetName(), acc_stat.GetMean(), acc_stat.GetMeanErr(), acc_stat.GetRMS(), acc_stat.GetN());
0117   printout(INFO,"Statistics","+  Accessed a total of %ld conditions (S:%6ld,L:%6ld,C:%6ld,M:%ld)",
0118            total.total(), total.selected, total.loaded, total.computed, total.missing, total_created);
0119   printout(INFO,"Statistics","+=========================================================================");
0120   // All done.
0121   return 1;
0122 }
0123 
0124 // first argument is the type from the xml file
0125 DECLARE_APPLY(DD4hep_ConditionExample_stress2,condition_example)