CMS 3D CMS Logo

Functions
eve_macros.cc File Reference
#include <vector>
#include <list>
#include <string>
#include <cmath>
#include <TEveElement.h>
#include <TEveGeoNode.h>
#include <TGeoNode.h>
#include "eve_macros.h"

Go to the source code of this file.

Functions

TEveGeoShape * clone (const TEveElement *element, TEveElement *parent)
 
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, unsigned int levels)
 
void set_tracker_endcap_visibility (TEveElement *tracker, bool visibility)
 
void show_tracker_endcap (TEveElement *tracker)
 

Function Documentation

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

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 TrackValidation_cff::_addSelectorsByHp(), TrackValidation_cff::_addSelectorsByOriginalAlgoMask(), TrackValidation_cff::_addSelectorsBySrc(), trackselectionRefitting::_getModule(), runMETCorrectionsAndUncertainties.RunMETCorrectionsAndUncertainties::ak4JetReclustering(), applyDeepBtagging_cff::applyDeepBtagging(), BasicTrajectoryState::BasicTrajectoryState(), edm::Exception::categoryCode(), ConvertedPhotonProducer::cleanCollections(), clone(), FastTrackerRecHit::clone_(), DQMStore::cloneLumiHistograms(), DQMStore::cloneRunHistograms(), edm::service::cmssw_stacktrace_fork(), runMETCorrectionsAndUncertainties.RunMETCorrectionsAndUncertainties::copyCentralMETProducer(), customNtuples::create_ntuple(), runMETCorrectionsAndUncertainties.RunMETCorrectionsAndUncertainties::createMVAMETModule(), MuonSeedFromRecHits::createSeed(), MuonSeedCreator::createSeed(), runMETCorrectionsAndUncertainties.RunMETCorrectionsAndUncertainties::createShiftedModules(), runMETCorrectionsAndUncertainties.RunMETCorrectionsAndUncertainties::createSmearedJetModule(), customiseMTVForBPix123Holes::customiseMTVForBPix123Holes(), dqmCopyRecursively(), eGammaCorrection::eGammaCorrection(), common_cff::ExtVar(), reco::GenParticle::GenParticle(), runMETCorrectionsAndUncertainties.RunMETCorrectionsAndUncertainties::getCorrectedMET(), SiStripConfigDb::getDcuDetIds(), runMETCorrectionsAndUncertainties.RunMETCorrectionsAndUncertainties::getVariations(), ctfseeding::HitExtractor::HitExtractor(), edm::IDVectorMap< ID, C, P >::insert(), edm::OwnVector< T, P >::insert(), runMETCorrectionsAndUncertainties.RunMETCorrectionsAndUncertainties::jetCleaning(), extraJets_MuEGFixMoriond2017::makeRecoJetCollection(), MaterialEffectsUpdator::mass(), miniAOD_tools::miniAOD_customizeCommon(), TrackingRegionsSeedingLayerSets::const_iterator::operator++(), SeedingLayerSetsLooper::LayerSetRange< T >::const_iterator::operator++(), SeedingLayerSetsHits::SeedingLayerSet::const_iterator::operator++(), ihd::const_iterator< ValueType, HitSetType >::operator++(), IntermediateHitTriplets::RegionLayerSets::const_iterator::operator++(), SeedingLayerSetsHits::const_iterator::operator++(), VertexCompatibleWithBeam::operator=(), edm::OwnArray< T, MAX_SIZE, P >::OwnArray(), edm::OwnVector< T, P >::OwnVector(), edm::ParameterDescriptionNode::ParameterDescriptionNode(), edm::RangeMap< det_id_type, edm::OwnVector< B > >::post_insert(), MassKinFitterCandProducer::produce(), ParticleDecayProducer::produce(), AssociationVectorSelector< KeyRefProd, CVal, KeySelector, ValSelector >::produce(), PixelTracksProducer::produce(), ConstrainedFitCandProducer< Fitter, InputCollection, OutputCollection, Init >::produce(), Merger< InputCollection, OutputCollection, P >::produce(), UniqueMerger< InputCollection, OutputCollection, P >::produce(), TrackCandidateProducer::produce(), ConvBremSeedProducer::produce(), SeedToTrackProducer::produce(), TrajectorySeedProducer::produce(), runMETCorrectionsAndUncertainties.RunMETCorrectionsAndUncertainties::produceMET(), edm::OwnArray< T, MAX_SIZE, P >::push_back(), edm::OwnVector< T, P >::push_back(), edm::RangeMap< det_id_type, edm::OwnVector< B > >::put(), cms::Exception::raise(), runMETCorrectionsAndUncertainties.RunMETCorrectionsAndUncertainties::recomputeRawMetFromPfcs(), pfTools::reconfigurePF2PATTaus(), TrackingRegion::restrictedRegion(), SeedGeneratorForCRack::seeds(), SeedGeneratorForCosmics::seeds(), edm::OwnVector< T, P >::set(), Propagator::setMaxDirectionChange(), jetTools::setupBTagging(), jetTools::setupJetCorrections(), SplittingConfigurableHisto::SplittingConfigurableHisto(), pfTools::switchToPFJets(), trackTools.MakePATTrackCandidates::toolCode(), tauTools.AddTauCollection::toolCode(), common_cff::Var(), reco::PFTau::~PFTau(), and PhysicsTools::Calibration::VarProcessor::~VarProcessor().

136 {
137  TEveGeoShape* shape = new TEveGeoShape( get_name(element), get_title(element) );
138 
139  std::unique_ptr<TGeoMatrix> matrix( get_transform(element) );
140  shape->SetTransMatrix( matrix.get() );
141  delete matrix;
142 
143  TEveGeoShapeExtract extract; // FIXME put name and title here...
144  extract.SetShape( (TGeoShape *) get_shape(element)->Clone() );
145  extract.SetTrans( trans.Array() );
146  extract.SetRnrSelf( true );
147  extract.SetRnrElements( true );
148 
149  TEveGeoShape * clone = TEveGeoShape::ImportShapeExtract( &extract, parent );
150  return clone;
151 }
const char * get_title(const TEveElement *element)
Definition: eve_macros.cc:28
const TGeoShape * get_shape(const TEveElement *element)
Definition: eve_macros.cc:66
TGeoMatrix * get_transform(const TEveElement *element)
Definition: eve_macros.cc:95
int extract(std::vector< int > *output, const std::string &dati)
TEveGeoShape * clone(const TEveElement *element, TEveElement *parent)
Definition: eve_macros.cc:135
const char * get_name(const TEveElement *element)
Definition: eve_macros.cc:13
void expand_node ( TEveElement *  element)

Definition at line 43 of file eve_macros.cc.

References GetRecoTauVFromDQM_MC_cff::next.

Referenced by node_filter(), and set_color().

44 {
45  // force a TEveGeoNode to load all its children
46  if (TEveGeoNode * node = dynamic_cast<TEveGeoNode *>( element )) {
47  if (node->GetNChildren() == 0 && node->GetNode()->GetVolume()->GetNdaughters() > 0) {
48  TIter next(node->GetNode()->GetVolume()->GetNodes());
49  TGeoNode* dnode;
50  while ((dnode = (TGeoNode*) next()) != 0) {
51  TEveGeoNode* node_re = new TEveGeoNode(dnode);
52  node->AddElement(node_re);
53  }
54  }
55  return;
56  }
57  // a TEveGeoShape is always exanded
58  //if (TEveGeoShape * shape __attribute__ ((unused)) = dynamic_cast<TEveGeoShape *>( element )) {
59  // return;
60  //}
61  // a generic TEveElement has no knwledge on children expansion
62  return;
63 }
const char* get_name ( const TEveElement *  element)

Definition at line 13 of file eve_macros.cc.

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

13  {
14  // try as a TEveGeoNode or TEveGeoShape
15  if (const TEveGeoNode * node = dynamic_cast<const TEveGeoNode *>( element ))
16  return node->GetName();
17  if (const TEveGeoShape * shape = dynamic_cast<const TEveGeoShape *>( element ))
18  return shape->GetName();
19 
20  // try to access the element as a generic named object
21  if (const TNamed * named = dynamic_cast<const TNamed *>( element ))
22  return named->GetName();
23 
24  return 0;
25 }
const TGeoShape* get_shape ( const TEveElement *  element)

Definition at line 66 of file eve_macros.cc.

Referenced by clone().

66  {
67  // a TEveGeoNode, can look into its TGeoNode and retrieve the shape
68  if (const TEveGeoNode * node = dynamic_cast<const TEveGeoNode *>( element )) {
69  return node->GetNode()->GetVolume()->GetShape();
70  }
71  // a TEveGeoShape owns its shape
72  if (const TEveGeoShape * shape = dynamic_cast<const TEveGeoShape *>( element )) {
73  TEveGeoShape * nc_shape = const_cast<TEveGeoShape *>( shape );
74  return const_cast<const TGeoShape *>( nc_shape->GetShape() );
75  }
76  // a TEveElement is too generic, no way to get a shape
77  return 0;
78 }
TGeoShape* get_shape ( TEveElement *  element)

Definition at line 81 of file eve_macros.cc.

81  {
82  // a TEveGeoNode cannot modify its shape
83  //if (const TEveGeoNode * node __attribute__ ((unused)) = dynamic_cast<const TEveGeoNode *>( element )) {
84  // return 0;
85  //}
86  // a TEveGeoShape owns its shape, and can modifiy it
87  if (TEveGeoShape * shape = dynamic_cast<TEveGeoShape *>( element )) {
88  return shape->GetShape();
89  }
90  // a TEveElement is too generic, no way to get a shape
91  return 0;
92 }
const char* get_title ( const TEveElement *  element)

Definition at line 28 of file eve_macros.cc.

Referenced by clone().

28  {
29  // try as a TEveGeoNode or TEveGeoShape
30  if (const TEveGeoNode * node = dynamic_cast<const TEveGeoNode *>( element ))
31  return node->GetTitle();
32  if (const TEveGeoShape * shape = dynamic_cast<const TEveGeoShape *>( element ))
33  return shape->GetTitle();
34 
35  // try to access the element as a generic named object
36  if (const TNamed * named = dynamic_cast<const TNamed *>( element ))
37  return named->GetTitle();
38 
39  return 0;
40 }
TGeoMatrix* get_transform ( const TEveElement *  element)

Definition at line 95 of file eve_macros.cc.

References mps_fire::i, makeMuonMisalignmentScenario::matrix, and class-composition::nodes.

Referenced by clone().

95  {
96  if (const TEveGeoNode * node = dynamic_cast<const TEveGeoNode *>( element )) {
97  // a TEveGeoNode is a proxy to a TGeoNode, which knows its relative transformation wrt. its parent
98  // 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
99  std::vector< const TEveGeoNode * > nodes;
100  const TEveGeoTopNode * top = 0;
101 
102  while ((top = dynamic_cast<const TEveGeoTopNode *>( node )) == 0) {
103  // save the current node
104  nodes.push_back(node);
105 
106  // check that the node actually has any parents
107  TEveGeoNode * nc_node = const_cast<TEveGeoNode *>( node );
108  if (nc_node->BeginParents() == nc_node->EndParents())
109  return 0;
110 
111  // assume the firt parent is the good one, and check that the parent type is correct
112  node = dynamic_cast<const TEveGeoNode *>( * nc_node->BeginParents() );
113  if (node == 0)
114  return 0;
115  }
116  // reached the top level node, start from its (optional) global transormation
117  TGeoHMatrix * matrix = new TGeoHMatrix();
118  (const_cast<TEveGeoTopNode *>(top))->RefGlobalTrans().SetGeoHMatrix( *matrix );
119  for (unsigned int i = 0; i < nodes.size(); ++i)
120  *matrix *= *(nodes[i]->GetNode()->GetMatrix());
121  return matrix;
122  }
123 
124  if (const TEveGeoShape * shape = dynamic_cast<const TEveGeoShape *>( element )) {
125  // a TEveGeoShape knows the absolute transformation of its shape
126  TGeoHMatrix * matrix = new TGeoHMatrix();
127  (const_cast<TEveGeoShape *>(shape))->RefHMTrans().SetGeoHMatrix( *matrix );
128  return matrix;
129  }
130 
131  return 0;
132 }
void hide_tracker_endcap ( TEveElement *  tracker)

Definition at line 244 of file eve_macros.cc.

References set_tracker_endcap_visibility().

245 {
247 }
void set_tracker_endcap_visibility(TEveElement *tracker, bool visibility)
Definition: eve_macros.cc:226
bool is_leaf_node ( const TEveElement *  element)

Definition at line 177 of file eve_macros.cc.

Referenced by set_children_visibility().

178 {
179  // a TEveGeoNode can have unaccounted-for children
180  if (const TEveGeoNode * node = dynamic_cast<const TEveGeoNode *>( element )) {
181  return ((node->GetNChildren() == 0) and (node->GetNode()->GetVolume()->GetNdaughters() == 0));
182  }
183  // a TEveGeoShape always knows its children
184  if (const TEveGeoShape * shape = dynamic_cast<const TEveGeoShape *>( element )) {
185  return (shape->GetNChildren() == 0);
186  }
187  // default implementation
188  return (element->GetNChildren() == 0);
189 }
void set_children_visibility ( TEveElement *  element,
const std::string &  node_name,
const std::vector< std::string > &  children_name,
bool  visibility 
)

Definition at line 193 of file eve_macros.cc.

References get_name(), mps_fire::i, is_leaf_node(), dataset::name, or, and findQualityFiles::size.

Referenced by set_tracker_endcap_visibility().

194 {
195  // try to access the element as a named thingy
196  const char * name = get_name( element );
197  if (not name or strncmp(name, node_name.c_str(), node_name.size()))
198  // unnamed node, or wrong node
199  return;
200 
201  for (std::list<TEveElement *>::iterator j = element->BeginChildren(); j != element->EndChildren(); ++j) {
202  TEveElement * child = *j;
203  name = get_name( child );
204  if (not name)
205  // unnamed node, ignore it
206  continue;
207 
208  for (unsigned int i = 0; i < children_name.size(); ++i)
209  if (not strncmp(name, children_name[i].c_str(), children_name[i].size())) {
210  // change this child visibility
211  if (is_leaf_node( child )) {
212  child->SetRnrSelf( visibility );
213  child->SetRnrChildren( false );
214  } else {
215  child->SetRnrSelf( false );
216  child->SetRnrChildren( visibility );
217  }
218  break;
219  }
220  }
221  // notify the element that is had changed
222  element->ElementChanged(true, true);
223 }
size
Write out results.
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
bool is_leaf_node(const TEveElement *element)
Definition: eve_macros.cc:177
void set_color ( TEveElement *  element,
Color_t  color,
float  alpha,
unsigned int  levels 
)

Definition at line 154 of file eve_macros.cc.

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

Referenced by FWProxyBuilderBase::getHaveWindow(), FWProxyBuilderBase::scaleProduct(), and set_color().

155 {
156  if (not element)
157  return;
158 
159  // set this node's color
160  element->SetMainColor( color );
161  if (alpha > 1.) alpha = 1.;
162  if (alpha < 0.) alpha = 0.;
163  unsigned char transparency = (unsigned char) roundf(100. - (alpha * 100.));
164  element->SetMainTransparency( transparency );
165 
166  if (levels > 0) {
167  // set the node's children's color
168  expand_node( element );
169  for (std::list<TEveElement*>::iterator i = element->BeginChildren(); i != element->EndChildren(); ++i)
170  set_color( *i, color, alpha, levels - 1);
171  }
172  // notify the element that it has changed
173  element->ElementChanged(true, true);
174 }
float alpha
Definition: AMPTWrapper.h:95
void set_color(TEveElement *element, Color_t color, float alpha, unsigned int levels)
Definition: eve_macros.cc:154
void expand_node(TEveElement *element)
Definition: eve_macros.cc:43
void set_tracker_endcap_visibility ( TEveElement *  tracker,
bool  visibility 
)

Definition at line 226 of file eve_macros.cc.

References makeMuonMisalignmentScenario::endcap, and set_children_visibility().

Referenced by hide_tracker_endcap(), and show_tracker_endcap().

227 {
228  std::vector<std::string> endcap;
229  endcap.push_back("tec:TEC");
230  endcap.push_back("tidf:TIDF");
231  endcap.push_back("tidb:TIDB");
232  endcap.push_back("pixfwd:PixelForwardZPlus");
233  endcap.push_back("pixfwd:PixelForwardZMinus");
234  set_children_visibility( tracker, "tracker:Tracker", endcap, visibility );
235 }
void set_children_visibility(TEveElement *element, const std::string &node_name, const std::vector< std::string > &children_name, bool visibility)
Definition: eve_macros.cc:193
void show_tracker_endcap ( TEveElement *  tracker)

Definition at line 238 of file eve_macros.cc.

References set_tracker_endcap_visibility().

239 {
241 }
void set_tracker_endcap_visibility(TEveElement *tracker, bool visibility)
Definition: eve_macros.cc:226