Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-02-24 09:24:56

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_Alignment2Condition
0020 
0021 */
0022 // Framework include files
0023 #include "DD4hep/Printout.h"
0024 #include "DD4hep/Conditions.h"
0025 #include "DD4hep/Alignments.h"
0026 #include "DD4hep/AlignmentData.h"
0027 #include "DD4hep/detail/ConditionsInterna.h"
0028 #include "DD4hep/detail/AlignmentsInterna.h"
0029 
0030 #include "DD4hep/Factories.h"
0031 
0032 #include <cerrno>
0033 
0034 using namespace std;
0035 using namespace dd4hep;
0036 
0037 /// Plugin function: Alignment program example
0038 /**
0039  *  Factory: dd4hep_Alignment2Condition
0040  *
0041  *  \author  M.Frank
0042  *  \version 1.0
0043  *  \date    01/12/2016
0044  */
0045 static int Alignment_to_Condition (Detector& , int argc, char** argv)  {
0046   for(int i=0; i<argc && argv[i]; ++i)  {
0047     if ( 0 == ::strncmp("-help",argv[i],2) || 0 == ::strncmp("-?",argv[i],2) )  {
0048       /// Help printout describing the basic command line interface
0049       cout <<
0050         "Usage: -plugin <name>                                                         \n"
0051         "     name:   factory name     DD4hep_AlignmentExample_read_xml                \n"
0052         "\tArguments given: " << arguments(argc,argv) << endl << flush;
0053       ::exit(EINVAL);
0054     }
0055   }
0056 
0057   AlignmentCondition ac("alignment");
0058   ac->hash = ConditionKey(0,ConditionKey::itemCode(ac.name())).hash;
0059   
0060   printout(INFO,"Example","Alignment condition:  \"%s\"  Key:%016llX",ac.name(),ac->hash);
0061   printout(INFO,"Example","Alignment condition ptr:  %p",ac.ptr());
0062 
0063   Condition con(ac);
0064   AlignmentData& data = ac.data();
0065   printout(INFO,"Example","Alignment condition data: %p",(void*)&data);
0066   printout(INFO,"Example","Condition opaque pointer: %p",(void*)con.data().ptr());
0067   printout(INFO,"Example","Offset to opaque pointer: %uld",con->offset());
0068   printout(INFO,"Example","Computed Pointer:         %p",(void*)((char*)con.ptr()+con->offset()));
0069   printout(INFO,"Example","Computed payload pointer: %p",(void*)con->payload());
0070 
0071   Alignment align(ac);
0072   printout(INFO,"Example","Alignment object pointer: %p",(void*)align.ptr());
0073   printout(INFO,"Example","Alignment key:            %016llX",ac.key());
0074   printout(INFO,"Example","Condition key:            %016llX",con.key());
0075 
0076   return 1;
0077 }
0078 
0079 DECLARE_APPLY(DD4hep_Alignment2Condition,Alignment_to_Condition)