Back to home page

EIC code displayed by LXR

 
 

    


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

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 // Framework include files
0015 #include "AlignmentExampleObjects.h"
0016 #include "DD4hep/AlignmentsPrinter.h"
0017 #include "DD4hep/DD4hepUnits.h"
0018 #include "DD4hep/Objects.h"
0019 
0020 using namespace std;
0021 using namespace dd4hep;
0022 using namespace dd4hep::AlignmentExamples;
0023 
0024 /// Install the consitions and the alignment manager
0025 ConditionsManager dd4hep::AlignmentExamples::installManager(Detector& description)  {
0026   // Now we instantiate the conditions manager
0027   description.apply("DD4hep_ConditionsManagerInstaller",0,(char**)0);
0028   ConditionsManager manager = ConditionsManager::from(description);
0029   manager["PoolType"]       = "DD4hep_ConditionsLinearPool";
0030   manager["UserPoolType"]   = "DD4hep_ConditionsMapUserPool";
0031   manager["UpdatePoolType"] = "DD4hep_ConditionsLinearUpdatePool";
0032   manager.initialize();
0033   return manager;
0034 }
0035 
0036 /// Callback to process a single detector element
0037 int AlignmentDataAccess::operator()(DetElement de, int) const {
0038   vector<Alignment> alignments;
0039   alignmentsCollector(mapping,alignments)(de);
0040 
0041   // Let's go for the deltas....
0042   for(const auto& align : alignments )  {
0043     const Delta& delta = align.data().delta;
0044     if ( delta.hasTranslation() || delta.hasPivot() || delta.hasRotation() )  {}
0045   }
0046   // Keep it simple. To know how to access stuff,
0047   // simply look in DDDCore/src/AlignmentsPrinter.cpp...
0048   align::printElementPlacement(printLevel,"Example",de,mapping);
0049   return 1;
0050 }
0051 
0052 /// Callback to process a single detector element
0053 int AlignmentCreator::operator()(DetElement de, int)  const  {
0054   if ( de.ptr() != de.world().ptr() )  {
0055     Condition cond(de.path()+"#"+align::Keys::deltaName,align::Keys::deltaName);
0056     Delta&    delta = cond.bind<Delta>();
0057     cond->hash = ConditionKey(de.key(),align::Keys::deltaKey).hash;
0058     cond->setFlag(Condition::ACTIVE|Condition::ALIGNMENT_DELTA);
0059     /// Simply move everything by 1 mm in z. Not physical, but this is just an example...
0060     delta.translation.SetZ(delta.translation.Z()+0.1*dd4hep::cm);
0061     delta.rotation = RotationZYX(0.999,1.001,0.999);
0062     delta.flags |= Delta::HAVE_TRANSLATION|Delta::HAVE_ROTATION;
0063     if ( !manager.registerUnlocked(pool, cond) )   {
0064       printout(WARNING,"Example","++ Failed to register condition %s.",cond.name());
0065     }
0066     printout(printLevel,"Example","++ Adding manually alignments for %s",cond.name());
0067   }
0068   return 1;
0069 }