CMS 3D CMS Logo

Functions

/data/refman/pasoursint/CMSSW_5_3_8_patch3/src/Fireworks/Macros/eve_macros.h File Reference

#include <vector>
#include <string>
#include <Rtypes.h>

Go to the source code of this file.

Functions

TEveGeoShape * clone (const TEveElement *element, TEveElement *parent=0)
void expand_node (TEveElement *element)
const char * get_name (const TEveElement *element)
const TGeoShape * get_shape (const TEveElement *element)
TGeoShape * get_shape (TEveElement *element)
const char * get_title (const TEveElement *element)
TGeoMatrix * get_transform (const TEveElement *element)
void hide_tracker_endcap (TEveElement *tracker)
bool is_leaf_node (const TEveElement *element)
void set_children_visibility (TEveElement *element, const std::string &node_name, const std::vector< std::string > &children_name, bool visibility)
void set_color (TEveElement *element, Color_t color, float alpha=1.0, unsigned int levels=0)
void set_tracker_endcap_visibility (TEveElement *tracker, bool visibility)
void show_tracker_endcap (TEveElement *tracker)

Function Documentation

TEveGeoShape* clone ( const TEveElement *  element,
TEveElement *  parent = 0 
)

Definition at line 135 of file eve_macros.cc.

References clone(), extract(), get_name(), get_shape(), get_title(), get_transform(), and makeMuonMisalignmentScenario::matrix.

Referenced by ConvertedPhotonProducer::cleanCollections(), TiXmlDocument::Clone(), TiXmlDeclaration::Clone(), TiXmlText::Clone(), TiXmlElement::Clone(), TiXmlUnknown::Clone(), clone(), TiXmlComment::Clone(), edm::value_ptr< ParameterSet >::createFrom(), MuonSeedCreator::createSeed(), MuonSeedFromRecHits::createSeed(), dqmCopyRecursively(), SiStripConfigDb::getDcuDetIds(), HcalUtilsClient::getHisto(), edm::IDVectorMap< ID, C, P >::insert(), SiStripRecHitMatcher::match(), VertexCompatibleWithBeam::operator=(), edm::RangeMap< det_id_type, edm::OwnVector< B > >::post_insert(), RoadSearchTrackCandidateMakerAlgorithm::PrepareTrackCandidates(), AssociationVectorSelector< KeyRefProd, CVal, KeySelector, ValSelector >::produce(), Merger< InputCollection, OutputCollection, P >::produce(), ParticleDecayProducer::produce(), PixelTracksProducer::produce(), MassKinFitterCandProducer::produce(), ConstrainedFitCandProducer< Fitter, InputCollection, OutputCollection, Init >::produce(), DeDxEstimatorProducerPixelTripplet::produce(), ConvBremSeedProducer::produce(), edm::OwnVector< T, P >::push_back(), edm::OwnArray< T, MAX_SIZE, P >::push_back(), edm::RangeMap< det_id_type, edm::OwnVector< B > >::put(), SeedGeneratorForCRack::seeds(), and SeedGeneratorForCosmics::seeds().

{
  TEveGeoShape* shape = new TEveGeoShape( get_name(element), get_title(element) );

  std::auto_ptr<TGeoMatrix> matrix( get_transform(element) );
  shape->SetTransMatrix( matrix.get() );
  delete matrix;

  TEveGeoShapeExtract extract;                  // FIXME put name and title here...
  extract.SetShape( (TGeoShape *) get_shape(element)->Clone() );
  extract.SetTrans( trans.Array() );
  extract.SetRnrSelf( true );
  extract.SetRnrElements( true );

  TEveGeoShape * clone = TEveGeoShape::ImportShapeExtract( &extract, parent );
  return clone;
}
void expand_node ( TEveElement *  element)

Definition at line 26 of file vis_macros.cc.

References python::Node::node.

Referenced by node_filter(), and set_color().

{
   // force a TEveGeoNode to load all its children
   if (TEveGeoNode * node = dynamic_cast<TEveGeoNode *>( element )) {
      if (node->NumChildren() == 0 && node->GetNode()->GetVolume()->GetNdaughters() != 0) {
         TIter next(node->GetNode()->GetVolume()->GetNodes());
         TGeoNode* dnode;
         while ((dnode = (TGeoNode*) next()) != 0) {
            TEveGeoNode* node_re = new TEveGeoNode(dnode);
            node->AddElement(node_re);
         }
      }
      return;
   }
   // a TEveGeoShape is always exanded
   //if (TEveGeoShape * shape __attribute__ ((unused)) = dynamic_cast<TEveGeoShape *>( element )) {
   //  return;
   //}
   // a generic TEveElement has no knwledge on children expansion
   return;
}
const char* get_name ( const TEveElement *  element)

Definition at line 11 of file vis_macros.cc.

References python::Node::node.

Referenced by apply_filter(), clone(), get_root_object(), and set_children_visibility().

                                                    {
   // try as a TEveGeoNode or TEveGeoShape
   if (const TEveGeoNode * node = dynamic_cast<const TEveGeoNode *>( element ))
      return node->GetName();
   if (const TEveGeoShape * shape = dynamic_cast<const TEveGeoShape *>( element ))
      return shape->GetName();

   // try to access the element as a named thingy
   if (const TNamed * named = dynamic_cast<const TNamed *>( element ))
      return named->GetName();

   return 0;
}
const TGeoShape* get_shape ( const TEveElement *  element)

Definition at line 49 of file vis_macros.cc.

References python::Node::node.

Referenced by clone().

                                                           {
   // a TEveGeoNode, can look into its TGeoNode and retrieve the shape
   if (const TEveGeoNode * node = dynamic_cast<const TEveGeoNode *>( element )) {
      return node->GetNode()->GetVolume()->GetShape();
   }
   // a TEveGeoShape owns its shape
   if (const TEveGeoShape * shape = dynamic_cast<const TEveGeoShape *>( element )) {
      TEveGeoShape * nc_shape = const_cast<TEveGeoShape *>( shape );
      return const_cast<const TGeoShape *>( nc_shape->GetShape() );
   }
   // a TEveElement is too generic, no way to get a shape
   return 0;
}
TGeoShape* get_shape ( TEveElement *  element)

Definition at line 64 of file vis_macros.cc.

                                               {
   // a TEveGeoNode cannot modify its shape
   //if (const TEveGeoNode * node __attribute__ ((unused)) = dynamic_cast<const TEveGeoNode *>( element )) {
   //  return 0;
   //}
   // a TEveGeoShape owns its shape, and can modifiy it
   if (TEveGeoShape * shape = dynamic_cast<TEveGeoShape *>( element )) {
      return shape->GetShape();
   }
   // a TEveElement is too generic, no way to get a shape
   return 0;
}
const char* get_title ( const TEveElement *  element)

Definition at line 28 of file eve_macros.cc.

References python::Node::node.

Referenced by clone().

                                                     {
  // try as a TEveGeoNode or TEveGeoShape
  if (const TEveGeoNode * node = dynamic_cast<const TEveGeoNode *>( element ))
    return node->GetTitle();
  if (const TEveGeoShape * shape = dynamic_cast<const TEveGeoShape *>( element ))
    return shape->GetTitle();

  // try to access the element as a generic named object
  if (const TNamed * named = dynamic_cast<const TNamed *>( element ))
    return named->GetTitle();

  return 0;
}
TGeoMatrix* get_transform ( const TEveElement *  element)

Definition at line 95 of file eve_macros.cc.

References i, makeMuonMisalignmentScenario::matrix, and python::Node::node.

Referenced by clone().

                                                          {
  if (const TEveGeoNode * node = dynamic_cast<const TEveGeoNode *>( element )) {
    // a TEveGeoNode is a proxy to a TGeoNode, which knows its relative transformation wrt. its parent
    // so we follow the TEveGeoNode hierarchy up to a TEveGeoTopNode, then jump to its TGeoManager, and go back down the branches to the TEveGeoNode's TGeoNode
    std::vector< const TEveGeoNode * > nodes;
    const TEveGeoTopNode * top = 0;

    while ((top = dynamic_cast<const TEveGeoTopNode *>( node )) == 0) {
      // save the current node
      nodes.push_back(node);

      // check that the node actually has any parents
      TEveGeoNode * nc_node = const_cast<TEveGeoNode *>( node );
      if (nc_node->BeginParents() == nc_node->EndParents())
        return 0;

      // assume the firt parent is the good one, and check that the parent type is correct
      node = dynamic_cast<const TEveGeoNode *>( * nc_node->BeginParents() );
      if (node == 0)
        return 0;
    }
    // reached the top level node, start from its (optional) global transormation
    TGeoHMatrix * matrix = new TGeoHMatrix();
    (const_cast<TEveGeoTopNode *>(top))->RefGlobalTrans().SetGeoHMatrix( *matrix );
    for (unsigned int i = 0; i < nodes.size(); ++i)
      *matrix *= *(nodes[i]->GetNode()->GetMatrix());
    return matrix;
  }

  if (const TEveGeoShape * shape = dynamic_cast<const TEveGeoShape *>( element )) {
    // a TEveGeoShape knows the absolute transformation of its shape
    TGeoHMatrix * matrix = new TGeoHMatrix();
    (const_cast<TEveGeoShape *>(shape))->RefHMTrans().SetGeoHMatrix( *matrix );
    return matrix;
  }

  return 0;
}
void hide_tracker_endcap ( TEveElement *  tracker)

Definition at line 167 of file vis_macros.cc.

References set_tracker_endcap_visibility().

bool is_leaf_node ( const TEveElement *  element)

Definition at line 100 of file vis_macros.cc.

References python::Node::node.

Referenced by set_children_visibility().

{
   // a TEveGeoNode can have unaccounted-for children
   if (const TEveGeoNode * node = dynamic_cast<const TEveGeoNode *>( element )) {
      return ((node->NumChildren() == 0) and (node->GetNode()->GetVolume()->GetNdaughters() == 0));
   }
   // a TEveGeoShape always knows its children
   if (const TEveGeoShape * shape = dynamic_cast<const TEveGeoShape *>( element )) {
      return (shape->NumChildren() == 0);
   }
   // default implementation
   return (element->NumChildren() == 0);
}
void set_children_visibility ( TEveElement *  element,
const std::string &  node_name,
const std::vector< std::string > &  children_name,
bool  visibility 
)

Definition at line 116 of file vis_macros.cc.

References get_name(), i, is_leaf_node(), j, mergeVDriftHistosByStation::name, and findQualityFiles::size.

Referenced by set_tracker_endcap_visibility().

{
   // try to access the element as a named thingy
   const char * name = get_name( element );
   if (not name or strncmp(name, node_name.c_str(), node_name.size()))
      // unnamed node, or wrong node
      return;

   for (std::list<TEveElement *>::iterator j = element->BeginChildren(); j != element->EndChildren(); ++j) {
      TEveElement * child = *j;
      name = get_name( child );
      if (not name)
         // unnamed node, ignore it
         continue;

      for (unsigned int i = 0; i < children_name.size(); ++i)
         if (not strncmp(name, children_name[i].c_str(), children_name[i].size())) {
            // change this child visibility
            if (is_leaf_node( child )) {
               child->SetRnrSelf( visibility );
               child->SetRnrChildren( false );
            } else {
               child->SetRnrSelf( false );
               child->SetRnrChildren( visibility );
            }
            break;
         }
   }
   // notify the element that is had changed
   element->ElementChanged(true, true);
}
void set_color ( TEveElement *  element,
Color_t  color,
float  alpha = 1.0,
unsigned int  levels = 0 
)

Definition at line 77 of file vis_macros.cc.

References expand_node(), i, and set_color().

Referenced by set_color().

{
   if (not element)
      return;

   // set this node's color
   element->SetMainColor( color );
   if (alpha > 1.) alpha = 1.;
   if (alpha < 0.) alpha = 0.;
   unsigned char transparency = (unsigned char) roundf(100. - (alpha * 100.));
   element->SetMainTransparency( transparency );

   if (levels > 0) {
      // set the node's children's color
      expand_node( element );
      for (std::list<TEveElement*>::iterator i = element->BeginChildren(); i != element->EndChildren(); ++i)
         set_color( *i, color, alpha, levels - 1);
   }
   // notify the element that it has changed
   element->ElementChanged(true, true);
}
void set_tracker_endcap_visibility ( TEveElement *  tracker,
bool  visibility 
)

Definition at line 149 of file vis_macros.cc.

References Reference_intrackfit_cff::endcap, and set_children_visibility().

Referenced by hide_tracker_endcap(), and show_tracker_endcap().

{
   std::vector<std::string> endcap;
   endcap.push_back("tec:TEC");
   endcap.push_back("tidf:TIDF");
   endcap.push_back("tidb:TIDB");
   endcap.push_back("pixfwd:PixelForwardZPlus");
   endcap.push_back("pixfwd:PixelForwardZMinus");
   set_children_visibility( tracker, "tracker:Tracker", endcap, visibility );
}
void show_tracker_endcap ( TEveElement *  tracker)

Definition at line 161 of file vis_macros.cc.

References set_tracker_endcap_visibility().