12 #include "St_base/StMessMgr.h"
13 #include "StiDetector.h"
14 #include "StiPlacement.h"
15 #include "StiCompositeTreeNode.h"
16 #include "StiDetectorBuilder.h"
17 #include "StiDetectorTreeBuilder.h"
18 #include "StlUtilities.h"
25 mnodefactory(
StiToolkit::instance()->getDetectorNodeFactory()),
28 LOG_INFO <<
"StiDetectorTreeBuilder::StiDetectorTreeBuilder() : Started/Done"<<endm;
36 LOG_INFO <<
"StiDetectorTreeBuilder::build() : Started"<<endm;
39 LOG_INFO <<
"StiDetectorTreeBuilder::build()\tError!\troot tree already built"<<endm;
45 LOG_INFO <<
"StiDetectorTreeBuilder::build() : Build root"<<endm;
49 LOG_INFO <<
"StiDetectorTreeBuilder::build() : Sort Tree"<<endm;
55 LOG_INFO <<
"StiDetectorTreeBuilder::build() : Index Tree"<<endm;
59 LOG_INFO <<
"StiDetectorTreeBuilder::build() : Done"<<endm;
73 fwd->
setName(
"forwardrapidity");
74 bwd->
setName(
"backwardrapidity");
77 midKey.key =
static_cast<double>(StiPlacement::kMidRapidity);
79 fwdKey.key =
static_cast<double>(StiPlacement::kForwardRapidity);
81 bwdKey.key =
static_cast<double>(StiPlacement::kBackwardRapidity);
102 tempOrderKey.key =
static_cast<double>( placement->getRegion() );
103 mySameOrderKey.morderKey = tempOrderKey;
104 StiDetectorNodeVector::iterator where = find_if(
mroot->
begin(),
mroot->
end(), mySameOrderKey);
108 LOG_ERROR <<
"StiDetectorContainer::build() : mid-rapidity region not found - where==0"<<endm;
116 StiPlacement::StiRegion theRegion = layer->getPlacement()->getRegion();
122 if ( theRegion == StiPlacement::kMidRapidity ) {
123 radius.key = place->getLayerRadius();
124 radstring =
"_radius";
127 LOG_ERROR <<
"StiDetectorBuiler::addToTree() : unkown region:\t"<<theRegion
128 <<
"\tfrom detector:\t"<<layer->
getName()<<
"\tabort"<<endm;
135 refAngle.key = layer->getPlacement()->getLayerAngle();
136 string phistring =
"_refAngle";
146 if (phinode->
getData()) phinode =
hangWhere(radialnode, refAngle, phistring,1);
149 layer->setTreeNode(phinode);
156 string& keystring,
int newOne)
159 mySameOrderKey.morderKey = order;
161 StiDetectorNodeVector::iterator where = find_if(parent->
begin(), parent->
end(), mySameOrderKey);
163 if (newOne || where == parent->
end()) {
167 sprintf(tempname,
"_%f", order.key);
168 keystring.append(tempname);
169 string newname = parent->
getName();
170 newname.append(keystring);
const string & getName() const
Return the name of the node.
StiDetectorNode * hangWhere(StiDetectorNode *parent, const StiOrderKey &order, string &keystring, int newOne=0)
Decide where to hang the detector object on the tree.
void addToTree(StiDetector *)
Actually hang an individual detector object on the tree.
StiDetectorNode * mroot
Store a pointer to the root of the tree.
T * getData() const
Return a (non-const!) pointer to the data hung on this node.
StiDetectorNode * build(StiDetectorBuilder *builder)
Build the Detector model.
void loopOnDetectors()
Iterate over the detector objects served by StiDetectorBuilder.
StiDetectorTreeBuilder()
Default Contstructor.
Factory< StiDetectorNode > * mnodefactory
This object is assumed not to be owned by this class.
void buildRoot()
Assemble detector objects into tree.
StiDetectorBuilder * mDetectorBuilder
Store a pointer to the StiDetectorBuilder instance.
virtual void add(StiCompositeTreeNode *)
Add a child to this node.
void setName(const string &)
Set the name of the node.
vec_type::iterator begin()
Provide random access iterator to the beginning of the vector of children.
virtual ~StiDetectorTreeBuilder()
Default Destructor.
vec_type::iterator end()
Provide random access iterator to the end of the vector of children.
StiDetectorNode * mregion
Pointer to the current region in the tree (e.g., mid rapidity)
void setData(T *)
Set the data to be hung on the node.
void setOrderKey(const StiOrderKey &)
Set the order-key for the node.
const string & getName() const
Get the name of the object.