CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
Enumerations | Functions
eve_filter.h File Reference
#include <vector>
#include <string>
#include "TPRegexp.h"

Go to the source code of this file.

Enumerations

enum  { do_nothing = 0, do_hide = 1, do_remove = 2 }
 

Functions

void apply_filter (TEveElement *node, int simplify=do_hide, bool verbose=false)
 
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=do_hide, bool verbose=false)
 
void split_path (const std::string &path, std::string &name, std::vector< std::string > &parents)
 

Enumeration Type Documentation

anonymous enum
Enumerator
do_nothing 
do_hide 
do_remove 

Definition at line 12 of file eve_filter.h.

12  {
13  do_nothing = 0,
14  do_hide = 1,
15  do_remove = 2
16 };

Function Documentation

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

Definition at line 178 of file eve_filter.cc.

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

178  {
179  if (node == 0)
180  return;
181 
182  if (verbose)
183  std::cout << get_name(node) << " (look inside...)" << std::endl;
184 
185  node_filter( node, simplify );
186  node->ElementChanged( true, true );
187 
188  std::cout << "found " << matching_nodes << " matching nodes" << std::endl;
189 }
void node_filter(TEveElement *node, int simplify, bool verbose)
Definition: eve_filter.cc:76
unsigned int matching_nodes
Definition: eve_filter.cc:27
tuple node
Definition: Node.py:50
tuple cout
Definition: gather_cfg.py:121
const char * get_name(const TEveElement *element)
Definition: eve_macros.cc:13
void dump ( void  )

Definition at line 171 of file eve_filter.cc.

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

171  {
172  std::cout << parents.fPattern << std::endl;
173  for (unsigned int i = 0; i < filters.size(); ++i)
174  std::cout << '\t' << std::setw(32) << std::left << filters[i].fPattern << '\t' << colors[i] << std::endl;
175 }
int i
Definition: DBlmapReader.cc:9
TPRegexp parents
Definition: eve_filter.cc:24
std::vector< TPRegexp > filters
Definition: eve_filter.cc:25
vector< Color_t > colors
tuple cout
Definition: gather_cfg.py:121
TEveElement* get_root_object ( const char *  name)

Definition at line 192 of file eve_filter.cc.

References get_name(), i, n, and or.

Referenced by calo_filter().

193 {
194  for (TEveElement::List_i i = gEve->GetScenes()->BeginChildren(); i != gEve->GetScenes()->EndChildren(); ++i) {
195  TEveScene * scene = dynamic_cast<TEveScene *> (*i);
196  if (not scene)
197  continue;
198  for (TEveElement::List_i n = scene->BeginChildren(); n != scene->EndChildren(); ++n) {
199  const char* obj_name = get_name( *n );
200  if (obj_name == 0 or strcmp(name, obj_name))
201  continue;
202 
203  return *n;
204  }
205  }
206 
207  return 0;
208 }
int i
Definition: DBlmapReader.cc:9
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::EventIDconst &, edm::Timestampconst & > 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 149 of file eve_filter.cc.

References colors, asciidump::elements, filters, first, i, make_filter(), matching_nodes, parents, edm::second(), and split_path().

Referenced by calo_filter().

149  {
150  std::vector< std::string > all_parents;
151  std::vector< std::string > all_names;
152 
153  for (unsigned int i = 0; i < elements.size(); ++i) {
154  std::vector< std::string > s_parents;
155  std::string s_name;
156  split_path( elements[i].first, s_name, s_parents );
157  all_names.push_back( s_name );
158  all_parents.insert( all_parents.end(), s_parents.begin(), s_parents.end() );
159 
160  colors.push_back( elements[i].second );
161  }
162 
163  parents = make_filter( all_parents );
164  for (unsigned int i = 0; i < all_names.size(); ++i)
165  filters.push_back( make_filter( all_names[i] ) );
166 
167  matching_nodes = 0;
168 }
int i
Definition: DBlmapReader.cc:9
TPRegexp parents
Definition: eve_filter.cc:24
unsigned int matching_nodes
Definition: eve_filter.cc:27
list elements
Definition: asciidump.py:414
std::vector< TPRegexp > filters
Definition: eve_filter.cc:25
U second(std::pair< T, U > const &p)
vector< Color_t > colors
TPRegexp make_filter(const std::string &token)
Definition: eve_filter.cc:42
bool first
Definition: L1TdeRCT.cc:94
void split_path(const std::string &path, std::string &name, std::vector< std::string > &parents)
Definition: eve_filter.cc:29
TPRegexp make_filter ( const std::string &  token)

Definition at line 42 of file eve_filter.cc.

References alcazmumu_cfi::filter, and ns_name_index().

Referenced by init_filter().

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

Definition at line 54 of file eve_filter.cc.

References alcazmumu_cfi::filter, i, and ns_name_index().

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

Definition at line 76 of file eve_filter.cc.

References colors, gather_cfg::cout, do_hide, do_nothing, do_remove, expand_node(), filters, newFWLiteAna::found, i, dataformats::indent(), matching_nodes, node_filter(), and parents.

Referenced by apply_filter(), and node_filter().

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

Definition at line 29 of file eve_filter.cc.

References split.

Referenced by init_filter().

29  {
30  split( path, parents, '/', false );
31  if (parents.empty()) {
32  name = "";
33  } else {
34  name = parents.back();
35  parents.pop_back();
36  }
37 }
TPRegexp parents
Definition: eve_filter.cc:24
list path
Definition: scaleCards.py:51
double split
Definition: MVATrainer.cc:139