Exemple #1
0
 static long dump(DetElement de,int level, bool sensitive_only) {
   const DetElement::Children& c = de.children();
   if ( !sensitive_only || 0 != de.volumeID() )  {
     PlacedVolume place = de.placement();
     const TGeoNode* node = place.ptr();
     char sens = place.volume().isSensitive() ? 'S' : ' ';
     int value = flag;
     char fmt[128];
     switch(value)  {
     case 0:
       ::snprintf(fmt,sizeof(fmt),"%03d %%-%ds %%s #Dau:%%d VolID:%%08X Place:%%p  %%c",level+1,2*level+1);
       printout(INFO,"DetectorDump",fmt,"",de.path().c_str(),int(c.size()),
                (unsigned long)de.volumeID(), (void*)node, sens);
       break;
     case 1:
       ::snprintf(fmt,sizeof(fmt),"%03d %%-%ds Detector: %%s #Dau:%%d VolID:%%p",level+1,2*level+1);
       printout(INFO,"DetectorDump", fmt, "", de.path().c_str(),
                int(c.size()), (void*)de.volumeID());
       ::snprintf(fmt,sizeof(fmt),"%03d %%-%ds Placement: %%s   %%c",level+1,2*level+3);
       printout(INFO,"DetectorDump",fmt,"", de.placementPath().c_str(), sens);
       break;
     default:
       break;
     }
   }
   for (DetElement::Children::const_iterator i = c.begin(); i != c.end(); ++i)
     dump((*i).second,level+1,sensitive_only);
   return 1;
 }
template<typename T> Condition ConditionsCreator::make_condition(DetElement de, const string& name, T val)  const {
  Condition cond(de.path()+"#"+name, name);
  T& value   = cond.bind<T>();
  value      = val;
  cond->hash = ConditionKey::hashCode(de,name);
  return cond;
}
/// Callback to process a single detector element
int ConditionsDependencyCreator::operator()(DetElement de, int)  const  {
  ConditionKey      key(de,"derived_data");
  ConditionKey      target1(de,"derived_data/derived_1");
  ConditionKey      target2(de,"derived_data/derived_2");
  ConditionKey      target3(de,"derived_data/derived_3");
  DependencyBuilder build_1(de, target1.item_key(), call1);
  DependencyBuilder build_2(de, target2.item_key(), call2);
  DependencyBuilder build_3(de, target3.item_key(), call3);
  //DependencyBuilder build_1(de, "derived_data/derived_1", call1);
  //DependencyBuilder build_2(de, "derived_data/derived_2", call2);
  //DependencyBuilder build_3(de, "derived_data/derived_3", call3);

  // Compute the derived stuff
  build_1.add(key);

  build_2.add(key);
  build_2.add(target1);
  
  build_3.add(key);
  build_3.add(target1);
  build_3.add(target2);

  content.addDependency(build_1.release());
  content.addDependency(build_2.release());
  content.addDependency(build_3.release());
  printout(printLevel,"Example","++ Added derived conditions dependencies for %s",de.path().c_str());
  return 1;
}
Exemple #4
0
 static long cache(DetElement de) {
   const DetElement::Children& c = de.children();
   de.worldTransformation();
   de.parentTransformation();
   de.placementPath();
   de.path();
   for (DetElement::Children::const_iterator i = c.begin(); i != c.end(); ++i)
     cache((*i).second);
   return 1;
 }
 /// Dump method.
 virtual int operator()(DetElement de,int level)  const  {
   const DetElement::Children& children = de.children();
   PlacedVolume place = de.placement();
   char sens = place.volume().isSensitive() ? 'S' : ' ';
   char fmt[128], tmp[32];
   ::snprintf(tmp,sizeof(tmp),"%03d/",level+1);
   ::snprintf(fmt,sizeof(fmt),"%03d %%-%ds %%s #Dau:%%d VolID:%%08X %%c",level+1,2*level+1);
   printout(INFO,"DetectorDump",fmt,"",de.path().c_str(),int(children.size()),
            (unsigned long)de.volumeID(), sens);
   printer.prefix = string(tmp)+de.name();
   (printer)(de, level);
   return 1;
 }
/// Access optical surface data by its identifier
OpticalSurface OpticalSurfaceManager::opticalSurface(DetElement de, const string& nam)  const   {
  if ( de.isValid() )  {
    Object* o = access();
    string  n = de.path() + '#' + nam;
    TGeoOpticalSurface* surf = o->detector.manager().GetOpticalSurface(n.c_str());
    if ( surf ) return surf;
    auto i = o->opticalSurfaces.find(n);
    if ( i != o->opticalSurfaces.end() ) return (*i).second;
    return 0;
  }
  except("OpticalSurface",
         "++ Cannot access OpticalSurface %s without valid detector element!",nam.c_str());
  return OpticalSurface();
}
/// Callback to process a single detector element
int ConditionsCreator::operator()(DetElement de, int)  const  {
  Condition temperature = make_condition<double>(de,"temperature",1.222);
  Condition pressure    = make_condition<double>(de,"pressure",888.88);
  Condition derived     = make_condition<int>   (de,"derived_data",100);
  Condition dbl_table   = make_condition<vector<double> >(de,"double_table",{1.,2.,3.,4.,5.,6.,7.,8.,9.});
  Condition int_table   = make_condition<vector<int> >   (de,"int_table",{10,20,30,40,50,60,70,80,90});

  slice.manager.registerUnlocked(pool, temperature);
  slice.manager.registerUnlocked(pool, pressure);
  slice.manager.registerUnlocked(pool, derived);
  slice.manager.registerUnlocked(pool, dbl_table);
  slice.manager.registerUnlocked(pool, int_table);
  printout(printLevel,"Creator","++ Adding manually conditions for %s",de.path().c_str());
  return 5;
}
static void* create_printer(Detector& description, int argc,char** argv)  {
  PrintLevel print_level = INFO;
  string prefix = "", name = "";
  int    flags = 0, have_pool = 0, arg_error = false;
  for(int i=0; i<argc && argv[i]; ++i)  {
    if ( 0 == ::strncmp("-prefix",argv[i],4) )
      prefix = argv[++i];
    else if ( 0 == ::strncmp("-name",argv[i],5) )
      name = argv[++i];
    else if ( 0 == ::strncmp("-flags",argv[i],5) )
      flags = ::atol(argv[++i]);
    else if ( 0 == ::strncmp("-pool",argv[i],5) )
      have_pool = 1;
    else if ( 0 == ::strncmp("-print",argv[i],5) )
      print_level = dd4hep::printLevel(argv[++i]);
    else
      arg_error = true;
  }
  if ( arg_error )   {
    /// Help printout describing the basic command line interface
    cout <<
      "Usage: -plugin <name> -arg [-arg]                                             \n"
      "     name:   factory name(s)  DD4hep_ConditionsPrinter,                       \n"
      "                              dd4hep_AlignmentsPrinter                        \n"
      "                              dd4hep_AlignedVolumePrinter                     \n"
      "     -prefix <string>         Printout prefix for user customized output.     \n"
      "     -flags  <number>         Printout processing flags.                      \n"
      "     -pool                    Attach conditions user pool from                \n"
      "                              PluginTester's slice instance attached.       \n\n"
      "     -print <value>           Printout level for the printer object.          \n"
      "\tArguments given: " << arguments(argc,argv) << endl << flush;
    ::exit(EINVAL);
  }
  DetElement world = description.world();
  printout(INFO,"Printer","World=%s [%p]",world.path().c_str(),world.ptr());
  ConditionsSlice* slice = 0;
  if ( have_pool )   {
    PluginTester*    test  = description.extension<PluginTester>();
    slice = test->extension<ConditionsSlice>("ConditionsTestSlice");
  }
  PRINTER* p = (flags) ? new PRINTER(slice, prefix, flags) : new PRINTER(slice, prefix);
  p->printLevel = print_level;
  if ( !name.empty() ) p->name = name;
  return (void*)dynamic_cast<WRAPPER*>(createProcessorWrapper(p));
}