CMS 3D CMS Logo

Functions | Variables
eve_filter.cc File Reference
#include <vector>
#include <string>
#include <iostream>
#include <iomanip>
#include <utility>
#include "TPRegexp.h"
#include "TEveManager.h"
#include "TEveScene.h"
#include "TEveElement.h"
#include "TEveGeoNode.h"
#include "TGeoNode.h"
#include "TCollection.h"
#include "TObjString.h"
#include "split.h"
#include "eve_filter.h"
#include "eve_macros.h"

Go to the source code of this file.

Functions

void apply_filter (TEveElement *node, int simplify, bool verbose)
 
void dump (void)
 
TEveElement * get_root_object (const char *name)
 
void init_filter (const std::vector< std::pair< std::string, Color_t > > &elements)
 
TPRegexp make_filter (const std::string &token)
 
TPRegexp make_filter (const std::vector< std::string > &tokens)
 
void node_filter (TEveElement *node, int simplify, bool verbose)
 
static TPRegexp ns_name_index ("([[:alnum:]]+:[[:alnum:]-\\[\\]]+)(_[0-9]+)+")
 
void split_path (const std::string &path, std::string &name, std::vector< std::string > &parents)
 

Variables

std::vector< Color_t > colors
 
std::vector< TPRegexp > filters
 
unsigned int matching_nodes
 
TPRegexp parents
 

Function Documentation

void apply_filter ( TEveElement *  node,
int  simplify,
bool  verbose 
)

Definition at line 175 of file eve_filter.cc.

References gather_cfg::cout, get_name(), matching_nodes, and node_filter().

175  {
176  if (node == 0)
177  return;
178 
179  if (verbose)
180  std::cout << get_name(node) << " (look inside...)" << std::endl;
181 
182  node_filter( node, simplify );
183  node->ElementChanged( true, true );
184 
185  std::cout << "found " << matching_nodes << " matching nodes" << std::endl;
186 }
void node_filter(TEveElement *node, int simplify, bool verbose)
Definition: eve_filter.cc:73
unsigned int matching_nodes
Definition: eve_filter.cc:24
const char * get_name(const TEveElement *element)
Definition: eve_macros.cc:13
void dump ( void  )

Definition at line 168 of file eve_filter.cc.

References gather_cfg::cout, filters, mps_fire::i, and parents.

168  {
169  std::cout << parents.fPattern << std::endl;
170  for (unsigned int i = 0; i < filters.size(); ++i)
171  std::cout << '\t' << std::setw(32) << std::left << filters[i].fPattern << '\t' << colors[i] << std::endl;
172 }
TPRegexp parents
Definition: eve_filter.cc:21
std::vector< TPRegexp > filters
Definition: eve_filter.cc:22
Definition: colors.py:1
TEveElement* get_root_object ( const char *  name)

Definition at line 189 of file eve_filter.cc.

References get_name(), mps_fire::i, gen::n, and or.

Referenced by calo_filter().

190 {
191  for (TEveElement::List_i i = gEve->GetScenes()->BeginChildren(); i != gEve->GetScenes()->EndChildren(); ++i) {
192  TEveScene * scene = dynamic_cast<TEveScene *> (*i);
193  if (not scene)
194  continue;
195  for (TEveElement::List_i n = scene->BeginChildren(); n != scene->EndChildren(); ++n) {
196  const char* obj_name = get_name( *n );
197  if (obj_name == 0 or strcmp(name, obj_name))
198  continue;
199 
200  return *n;
201  }
202  }
203 
204  return 0;
205 }
The Signals That Services Can Subscribe To This is based on ActivityRegistry and is current per Services can connect to the signals distributed by the ActivityRegistry in order to monitor the activity of the application Each possible callback has some defined which we here list in angle e< void, edm::EventID const &, edm::Timestamp const & > We also list in braces which AR_WATCH_USING_METHOD_ is used for those or
Definition: Activities.doc:12
const char * get_name(const TEveElement *element)
Definition: eve_macros.cc:13
void init_filter ( const std::vector< std::pair< std::string, Color_t > > &  elements)

Definition at line 146 of file eve_filter.cc.

References allElectronIsolations_cfi::elements, filters, plotBeamSpotDB::first, mps_fire::i, make_filter(), matching_nodes, parents, edm::second(), split_path(), and AlCaHLTBitMon_QueryRunRegistry::string.

Referenced by calo_filter().

146  {
147  std::vector< std::string > all_parents;
148  std::vector< std::string > all_names;
149 
150  for (unsigned int i = 0; i < elements.size(); ++i) {
151  std::vector< std::string > s_parents;
152  std::string s_name;
153  split_path( elements[i].first, s_name, s_parents );
154  all_names.push_back( s_name );
155  all_parents.insert( all_parents.end(), s_parents.begin(), s_parents.end() );
156 
157  colors.push_back( elements[i].second );
158  }
159 
160  parents = make_filter( all_parents );
161  for (unsigned int i = 0; i < all_names.size(); ++i)
162  filters.push_back( make_filter( all_names[i] ) );
163 
164  matching_nodes = 0;
165 }
TPRegexp parents
Definition: eve_filter.cc:21
unsigned int matching_nodes
Definition: eve_filter.cc:24
std::vector< TPRegexp > filters
Definition: eve_filter.cc:22
U second(std::pair< T, U > const &p)
TPRegexp make_filter(const std::string &token)
Definition: eve_filter.cc:39
Definition: colors.py:1
void split_path(const std::string &path, std::string &name, std::vector< std::string > &parents)
Definition: eve_filter.cc:26
TPRegexp make_filter ( const std::string &  token)

Definition at line 39 of file eve_filter.cc.

References ALCARECOTkAlBeamHalo_cff::filter, ns_name_index(), and AlCaHLTBitMon_QueryRunRegistry::string.

Referenced by init_filter().

39  {
41  filter += "(";
42  if (ns_name_index.MatchB( token ))
43  filter += ((TObjString*)(ns_name_index.MatchS( token )->At(1)))->GetString();
44  else
45  filter += token;
46  filter += ")_[0-9]+";
47  return TPRegexp( filter.c_str() );
48 }
static TPRegexp ns_name_index("([[:alnum:]]+:[[:alnum:]-\\[\\]]+)(_[0-9]+)+")
TPRegexp make_filter ( const std::vector< std::string > &  tokens)

Definition at line 51 of file eve_filter.cc.

References ALCARECOTkAlBeamHalo_cff::filter, mps_fire::i, ns_name_index(), and AlCaHLTBitMon_QueryRunRegistry::string.

51  {
52  if (tokens.empty())
53  return TPRegexp();
54 
56  filter += "(";
57  if (ns_name_index.MatchB( tokens[0] ))
58  filter += ((TObjString*)(ns_name_index.MatchS( tokens[0] )->At(1)))->GetString();
59  else
60  filter += tokens[0];
61  for (unsigned int i = 1; i < tokens.size(); ++i) {
62  filter += "|";
63  if (ns_name_index.MatchB( tokens[i] ))
64  filter += ((TObjString*)(ns_name_index.MatchS( tokens[i] )->At(1)))->GetString();
65  else
66  filter += tokens[i];
67  }
68  filter += ")_[0-9]+";
69  return TPRegexp( filter.c_str() );
70 }
static TPRegexp ns_name_index("([[:alnum:]]+:[[:alnum:]-\\[\\]]+)(_[0-9]+)+")
void node_filter ( TEveElement *  node,
int  simplify,
bool  verbose 
)

Definition at line 73 of file eve_filter.cc.

References gather_cfg::cout, do_hide, do_nothing, do_remove, expand_node(), filters, runEdmFileComparison::found, mps_fire::i, summarizeEdmComparisonLogfiles::indent, matching_nodes, node_filter(), and parents.

Referenced by apply_filter(), and node_filter().

73  {
74  static int indent = 0;
75  ++indent;
76 
77  expand_node(node);
78 
79  for (TEveElement::List_i i = node->BeginChildren(); i != node->EndChildren(); ++i)
80  {
81  bool found = false;
82  TEveGeoNode * child = (TEveGeoNode*)(*i);
83  for (unsigned int det = 0; det < filters.size(); ++det) {
84  if (filters[det].MatchB( child->GetName() )) {
85  // found a selcted leaf
86  if (verbose) {
87  for (int _t = 0; _t < indent; ++_t) std::cout << " ";
88  std::cout << child->GetName() << " (found)" << std::endl;
89  }
90  child->SetRnrSelf( true );
91  child->SetMainColor( colors[det] );
92  // simplify - hide or delete its children
93  switch (simplify) {
94  case do_hide:
95  child->SetRnrSelf( true );
96  child->SetRnrChildren( false );
97  break;
98  case do_remove:
99  child->Destroy();
100  break;
101  case do_nothing:
102  break;
103  }
104 
105  found = true;
106  ++matching_nodes;
107  break; // breaks out of the loop on "det"
108  }
109  }
110  if (found)
111  continue;
112  else if (parents.MatchB( child->GetName() )) {
113  // found a possible parent
114  if (verbose) {
115  for (int _t = 0; _t < indent; ++_t) std::cout << " ";
116  std::cout << child->GetName() << " (look inside...)" << std::endl;
117  }
118  child->SetRnrSelf( false );
119  child->SetRnrChildren( true );
120  node_filter( child );
121  } else {
122  // enything else
123  if (verbose) {
124  for (int _t = 0; _t < indent; ++_t) std::cout << " ";
125  std::cout << child->GetName() << " (unused)" << std::endl;
126  }
127  // simplify - hide or delete this
128  switch (simplify) {
129  case do_hide:
130  child->SetRnrSelf( false );
131  child->SetRnrChildren( false );
132  break;
133  case do_remove:
134  child->Destroy();
135  break;
136  case do_nothing:
137  break;
138  }
139  }
140  }
141 
142  --indent;
143 }
TPRegexp parents
Definition: eve_filter.cc:21
void node_filter(TEveElement *node, int simplify, bool verbose)
Definition: eve_filter.cc:73
unsigned int matching_nodes
Definition: eve_filter.cc:24
std::vector< TPRegexp > filters
Definition: eve_filter.cc:22
Definition: colors.py:1
void expand_node(TEveElement *element)
Definition: eve_macros.cc:43
static TPRegexp ns_name_index ( "([[:alnum:]]+:[[:alnum:]-\\[\\]]+)(_[0-9]+)+"  )
static

Referenced by make_filter(), and split_path().

void split_path ( const std::string &  path,
std::string &  name,
std::vector< std::string > &  parents 
)

Definition at line 26 of file eve_filter.cc.

References ns_name_index(), and split.

Referenced by init_filter().

26  {
27  split( path, parents, '/', false );
28  if (parents.empty()) {
29  name = "";
30  } else {
31  name = parents.back();
32  parents.pop_back();
33  }
34 }
TPRegexp parents
Definition: eve_filter.cc:21
double split
Definition: MVATrainer.cc:139

Variable Documentation

std::vector<Color_t> colors

Definition at line 23 of file eve_filter.cc.

std::vector<TPRegexp> filters
unsigned int matching_nodes

Definition at line 24 of file eve_filter.cc.

Referenced by apply_filter(), init_filter(), and node_filter().

TPRegexp parents