CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
DummyEvelyser.cc
Go to the documentation of this file.
1 // -*- C++ -*-
2 //
3 // Package: Fireworks/Eve
4 // Class : DummyEvelyser
5 //
6 // Implementation:
7 // [Notes on implementation]
8 //
9 // Original Author: Matevz Tadel
10 // Created: Mon Jun 28 18:17:47 CEST 2010
11 // $Id: DummyEvelyser.cc,v 1.7 2010/07/15 13:02:04 matevz Exp $
12 //
13 
14 // system include files
15 
16 // user include files
20 
27 
30 
32 
34 
36 
37 #include "TEveManager.h"
38 #include "TEveTrack.h"
39 #include "TEveTrackPropagator.h"
40 
41 #include "TGeoManager.h"
42 #include "TGeoMatrix.h"
43 #include "TEveGeoNode.h"
44 #include "TEveTrans.h"
45 #include "TEveScene.h"
46 #include "TGLScenePad.h"
47 #include "TGLRnrCtx.h"
48 
50 {
51 public:
52  explicit DummyEvelyser(const edm::ParameterSet&);
54 
55 protected:
56  TEveGeoTopNode* make_node(const TString& path, Int_t vis_level, Bool_t global_cs);
57 
58 
59 
60 private:
61  virtual void beginJob();
62  virtual void endJob();
63 
64  virtual void beginRun(const edm::Run&, const edm::EventSetup&);
65  virtual void endRun (const edm::Run&, const edm::EventSetup&);
66 
67  virtual void analyze(const edm::Event&, const edm::EventSetup&);
68 
70 
72  TEveElement *m_geomList;
73  TEveTrackList *m_trackList;
74 
76  void remakeGeometry(const DisplayGeomRecord& dgRec);
77 };
78 
80 
81 
82 //
83 // constants, enums and typedefs
84 //
85 
86 //
87 // static data member definitions
88 //
89 
90 //==============================================================================
91 // constructors and destructor
92 //==============================================================================
93 
95  m_eve(),
96  m_trackTags(iConfig.getUntrackedParameter<edm::InputTag>("tracks")),
97  m_geomList(0),
98  m_trackList(0),
99  m_geomWatcher(this, &DummyEvelyser::remakeGeometry)
100 {}
101 
103 {}
104 
105 
106 //==============================================================================
107 // Protected helpers
108 //==============================================================================
109 
110 TEveGeoTopNode* DummyEvelyser::make_node(const TString& path, Int_t vis_level, Bool_t global_cs)
111 {
112  if (! gGeoManager->cd(path))
113  {
114  Warning("make_node", "Path '%s' not found.", path.Data());
115  return 0;
116  }
117 
118  TEveGeoTopNode* tn = new TEveGeoTopNode(gGeoManager, gGeoManager->GetCurrentNode());
119  tn->SetVisLevel(vis_level);
120  if (global_cs)
121  {
122  tn->RefMainTrans().SetFrom(*gGeoManager->GetCurrentMatrix());
123  }
124  m_geomList->AddElement(tn);
125 
126  return tn;
127 }
128 
129 
130 //==============================================================================
131 // member functions
132 //==============================================================================
133 
135 {
136  printf("DummyEvelyser::beginJob\n");
137 
138  if (m_eve)
139  {
140  // Make a track-list container we'll hold on until the end of the job.
141  // This allows us to preserve settings done by user via GUI.
142  m_trackList = new TEveTrackList("Tracks");
143  m_trackList->SetMainColor(6);
144  m_trackList->SetMarkerColor(kYellow);
145  m_trackList->SetMarkerStyle(4);
146  m_trackList->SetMarkerSize(0.5);
147 
148  m_trackList->IncDenyDestroy();
149 
150  TEveTrackPropagator *prop = m_trackList->GetPropagator();
151  prop->SetStepper(TEveTrackPropagator::kRungeKutta);
152  // Use simplified magnetic field provided by EveService.
154  }
155 }
156 
158 {
159  printf("DummyEvelyser::endJob\n");
160 
161  if (m_trackList)
162  {
163  m_trackList->DecDenyDestroy();
164  m_trackList = 0;
165  }
166 }
167 
168 //------------------------------------------------------------------------------
169 
171 {
172  printf("DummyEvelyser::beginRun\n");
173 
174  if (m_eve)
175  {
176  m_geomList = new TEveElementList("DummyEvelyzer Geom");
178  m_eve->getManager()->GetGlobalScene()->GetGLScene()->SetStyle(TGLRnrCtx::kWireFrame);
179  }
180 }
181 
183 {
184  printf("DummyEvelyser::endRun\n");
185 }
186 
187 //------------------------------------------------------------------------------
188 
190 {
191  m_geomList->DestroyElements();
192 
194  dgRec.get(geom);
195  TEveGeoManagerHolder _tgeo(const_cast<TGeoManager*>(geom.product()));
196 
197  // To have a full one, all detectors in one top-node:
198  // make_node("/cms:World_1/cms:CMSE_1", 4, kTRUE);
199 
200  make_node("/cms:World_1/cms:CMSE_1/tracker:Tracker_1", 1, kTRUE);
201  make_node("/cms:World_1/cms:CMSE_1/caloBase:CALO_1", 1, kTRUE);
202  make_node("/cms:World_1/cms:CMSE_1/muonBase:MUON_1", 1, kTRUE);
203 }
204 
206 {
207  printf("DummyEvelyser::analyze\n");
208 
209  if (m_eve)
210  {
211  // Remake geometry if it has changed.
212  m_geomWatcher.check(iSetup);
213 
214 
215  // Stripped down demo from Tracking twiki.
216 
217  using namespace edm;
218 
220  iEvent.getByLabel(m_trackTags, tracks);
221 
222  m_trackList->DestroyElements();
223 
224  // All top-level elements are removed from default event-store at
225  // the end of each event.
227 
228  int cnt = 0;
229  for (View<reco::Track>::const_iterator itTrack = tracks->begin();
230  itTrack != tracks->end(); ++itTrack, ++cnt)
231  {
232  TEveTrack* trk = fireworks::prepareTrack(*itTrack, m_trackList->GetPropagator());
233  trk->SetElementName (TString::Format("Track %d", cnt));
234  trk->SetElementTitle(TString::Format("Track %d, pt=%.3f", cnt, itTrack->pt()));
235  trk->MakeTrack();
236  trk->SetAttLineAttMarker(m_trackList);
237  m_trackList->AddElement(trk);
238 
239  // The display() function runs the GUI event-loop and shows
240  // whatever has been registered so far to eve.
241  // It returns when user presses the "Step" button (or "Continue" or
242  // "Next Event").
243  m_eve->display(std::string("DummyEvelyser::analyze done for:\n") + trk->GetName());
244  }
245  }
246 }
boost::indirect_iterator< typename seq_t::const_iterator > const_iterator
Definition: View.h:81
virtual void analyze(const edm::Event &, const edm::EventSetup &)
edm::Service< EveService > m_eve
TEveTrack * prepareTrack(const reco::Track &track, TEveTrackPropagator *propagator, const std::vector< TEveVector > &extraRefPoints=std::vector< TEveVector >())
Definition: TrackUtils.cc:70
#define DEFINE_FWK_MODULE(type)
Definition: MakerMacros.h:17
TEveElement * m_geomList
virtual void endJob()
DummyEvelyser(const edm::ParameterSet &)
list path
Definition: scaleCards.py:51
int iEvent
Definition: GenABIO.cc:243
edm::ESWatcher< DisplayGeomRecord > m_geomWatcher
virtual void beginRun(const edm::Run &, const edm::EventSetup &)
void get(HolderT &iHolder) const
virtual void endRun(const edm::Run &, const edm::EventSetup &)
void display(const std::string &info="")
Definition: EveService.cc:244
bool getByLabel(InputTag const &tag, Handle< PROD > &result) const
Definition: Event.h:356
TEveGeoTopNode * make_node(const TString &path, Int_t vis_level, Bool_t global_cs)
tuple tracks
Definition: testEve_cfg.py:39
TEveManager * getManager()
Definition: EveService.cc:263
T const * product() const
Definition: ESHandle.h:62
virtual void beginJob()
void setupFieldForPropagator(TEveTrackPropagator *prop)
Definition: EveService.cc:273
bool check(const edm::EventSetup &iSetup)
Definition: ESWatcher.h:59
edm::InputTag m_trackTags
void AddElement(TEveElement *el)
Definition: EveService.cc:282
TEveTrackList * m_trackList
void remakeGeometry(const DisplayGeomRecord &dgRec)
void AddGlobalElement(TEveElement *el)
Definition: EveService.cc:287
Definition: Run.h:33