Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-01-18 09:14:58

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 /* 
0015    Plugin invocation:
0016    ==================
0017    This plugin behaves like a main program.
0018    Invoke the plugin with something like this:
0019 
0020    geoPluginRun -plugin DD4hep_PersistencyExample_read_cond \
0021                 -output <file-name>
0022 
0023    Test the writing of a bunch of standard conditions objects
0024    to a native ROOT file.
0025 
0026 */
0027 // Framework include files
0028 #include "PersistencySetup.h"
0029 #include "DD4hep/Factories.h"
0030 #include "TFile.h"
0031 
0032 using namespace std;
0033 using namespace dd4hep;
0034 using namespace PersistencyExamples;
0035 
0036 /// Plugin function: Condition program example
0037 /**
0038  *  Factory: DD4hep_PersistencyExample_read_cond
0039  *
0040  *  \author  M.Frank
0041  *  \version 1.0
0042  *  \date    01/12/2016
0043  */
0044 static int persistency_example (Detector& /* description */, int argc, char** argv)  {
0045   string input;
0046   bool   arg_error = false;
0047   for(int i=0; i<argc && argv[i]; ++i)  {
0048     if ( 0 == ::strncmp("-input",argv[i],4) )
0049       input = argv[++i];
0050     else
0051       arg_error = true;
0052   }
0053   if ( arg_error || input.empty() )   {
0054     /// Help printout describing the basic command line interface
0055     cout <<
0056       "Usage: -plugin <name> -arg [-arg]                                             \n"
0057       "     name:   factory name     DD4hep_PersistencyExample_read_cond             \n"
0058       "     -input  <string>         Geometry input file                             \n"
0059       "     -iovs    <number>        Number of parallel IOV slots for processing.    \n"
0060       "\tArguments given: " << arguments(argc,argv) << endl << flush;
0061     ::exit(EINVAL);
0062   }
0063   
0064   PersistencyIO io;
0065   TFile*f = TFile::Open(input.c_str());
0066   f->ls();
0067   std::vector<dd4hep::Condition>* p = (std::vector<dd4hep::Condition>*)f->Get("Conditions");
0068   if ( p )  {
0069     int result = 0;
0070     for( const auto& cond : *p )  {
0071       //printout(INFO,"Example","+++ Reading condition object: %s",cond.name());
0072       result += printCondition(cond);
0073     }
0074     printout(ALWAYS,"Example","+++ Read successfully %ld conditions. Result=%d",p->size(),result);
0075   }
0076   else   {
0077     printout(ERROR,"Example","+++ ERROR +++ Failed to read object 'Conditions' from %s",f->GetName());
0078   }
0079   // All done.
0080   return 1;
0081 }
0082 
0083 // first argument is the type from the xml file
0084 DECLARE_APPLY(DD4hep_PersistencyExample_read_cond,persistency_example)