"README" did not exist on "c0e8614ba9e8b15d1cbaf56f876ffb9105667f15"
Newer
Older
Markus Frank
committed
// $Id: run_plugin.h 1663 2015-03-20 13:54:53Z gaede $
//==========================================================================
// AIDA Detector description implementation for LCD
Markus Frank
committed
//--------------------------------------------------------------------------
// Copyright (C) Organisation européenne pour la Recherche nucléaire (CERN)
// All rights reserved.
Markus Frank
committed
// For the licensing terms see $DD4hepINSTALL/LICENSE.
// For the list of contributors see $DD4hepINSTALL/doc/CREDITS.
Markus Frank
committed
// Author : M.Frank
//
//==========================================================================
// Framework include files
#include "DD4hep/LCDD.h"
#include "DD4hep/Printout.h"
#include "DD4hep/Conditions.h"
#include "DD4hep/DetFactoryHelper.h"
using namespace std;
using namespace DD4hep;
using namespace DD4hep::Geometry;
namespace {
/// Dump the conditions of one detectpr element
void dump_element(DetElement elt) {
string test = "ConditionsTest1";
Conditions conds = elt.conditions();
printout(INFO,test,"DetElement:%s # of conditons:%d",elt.path().c_str(),int(conds.count()));
const Conditions::Entries& entries = conds.entries();
for(Conditions::Entries::const_iterator i=entries.begin(); i!=entries.end(); ++i) {
Condition c((*i).second);
string type = c.type();
printout(INFO,test," %s Condition[%s]: %s [%s] Validity:%s",
Markus Frank
committed
c.detector().path().c_str(), type.c_str(), c.name().c_str(),
c.value().c_str(), c.validity().c_str());
Markus Frank
committed
c.bind<string>();
}
else if ( type == "temperature" ) {
Markus Frank
committed
c.bind<double>();
printout(INFO,test," %s : double value:%g ",
c.name().c_str(), c.get<double>());
}
else if ( type == "pressure" ) {
Markus Frank
committed
c.bind<double>();
printout(INFO,test," %s : double value:%g [%g hPa]",
c.name().c_str(), c.get<double>(),
_multiply(c.get<double>(),"1.0/hPa"));
}
else if ( type == "whatever" ) {
Markus Frank
committed
c.bind<vector<double> >();
const vector<double>& v = c.get<vector<double> >();
printout(INFO,test," %s : vector<double> size:%d = %s",
c.name().c_str(), int(v.size()), c.block().str().c_str());
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
}
printout(INFO,test, " Type: %s",typeName(c.typeInfo()).c_str());
}
}
/// Dump conditions tree of a detector element
void dump_conditions(DetElement elt) {
Conditions conds = elt.conditions();
const DetElement::Children& children = elt.children();
if ( !conds.isValid() )
printout(INFO,"ConditionsTest1","DetElement:%s NO CONDITIONS present",elt.path().c_str());
else
dump_element(elt);
for(DetElement::Children::const_iterator j=children.begin(); j!=children.end(); ++j)
dump_conditions((*j).second);
}
/// Test execution function
long conditions_test(LCDD& lcdd, int argc, char** argv) {
DetElement det = lcdd.world();
string args = "";
for(int i=0; i<argc; ++i) { args += argv[i], args += " "; };
printout(INFO,"ConditionsTest1","Args: %s",args.c_str());
dump_conditions(det);
return 1;
}
}
DECLARE_APPLY(ConditionsTest1,conditions_test)
namespace {
struct Callee {
void call(unsigned long tags, DetElement& det, void* param) {
if ( DetElement::CONDITIONS_CHANGED == (tags&DetElement::CONDITIONS_CHANGED) )
Markus Frank
committed
printout(INFO,"Callee","+++ Conditions update %s param:%p",det.path().c_str(),param);
if ( DetElement::PLACEMENT_CHANGED == (tags&DetElement::PLACEMENT_CHANGED) )
Markus Frank
committed
printout(INFO,"Callee","+++ Alignment update %s param:%p",det.path().c_str(),param);
}
};
/// Callback conditions tree of a detector element
void callback_install(DetElement elt, Callee* c) {
Position local, global;
const DetElement::Children& children = elt.children();
elt.localToWorld(local, global);
elt.callAtUpdate(DetElement::CONDITIONS_CHANGED|DetElement::PLACEMENT_CHANGED,c,&Callee::call);
for(DetElement::Children::const_iterator j=children.begin(); j!=children.end(); ++j)
callback_install((*j).second,c);
}
/// Test execution function
long callback_test(LCDD& lcdd, int /* argc */, char** /* argv */) {
DetElement det = lcdd.world();
callback_install(det, new Callee());
return 1;
}
}
DECLARE_APPLY(CallbackInstallTest,callback_test)