CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
List of all members | Public Member Functions | Protected Member Functions | Private Member Functions | Private Attributes
DisplayGeom Class Reference
Inheritance diagram for DisplayGeom:
edm::EDAnalyzer edm::EDConsumerBase

Public Member Functions

 DisplayGeom (const edm::ParameterSet &)
 
 ~DisplayGeom ()
 
- Public Member Functions inherited from edm::EDAnalyzer
void callWhenNewProductsRegistered (std::function< void(BranchDescription const &)> const &func)
 
 EDAnalyzer ()
 
ModuleDescription const & moduleDescription () const
 
std::string workerType () const
 
virtual ~EDAnalyzer ()
 
- Public Member Functions inherited from edm::EDConsumerBase
std::vector< ConsumesInfoconsumesInfo () const
 
 EDConsumerBase ()
 
ProductHolderIndexAndSkipBit indexFrom (EDGetToken, BranchType, TypeID const &) const
 
void itemsMayGet (BranchType, std::vector< ProductHolderIndexAndSkipBit > &) const
 
void itemsToGet (BranchType, std::vector< ProductHolderIndexAndSkipBit > &) const
 
std::vector
< ProductHolderIndexAndSkipBit >
const & 
itemsToGetFromEvent () const
 
void labelsForToken (EDGetToken iToken, Labels &oLabels) const
 
void modulesDependentUpon (const std::string &iProcessName, std::vector< const char * > &oModuleLabels) const
 
void modulesWhoseProductsAreConsumed (std::vector< ModuleDescription const * > &modules, ProductRegistry const &preg, std::map< std::string, ModuleDescription const * > const &labelsToDesc, std::string const &processName) const
 
bool registeredToConsume (ProductHolderIndex, bool, BranchType) const
 
bool registeredToConsumeMany (TypeID const &, BranchType) const
 
void updateLookup (BranchType iBranchType, ProductHolderIndexHelper const &)
 
virtual ~EDConsumerBase ()
 

Protected Member Functions

TEveGeoTopNode * make_node (const TString &path, Int_t vis_level, Bool_t global_cs)
 
- Protected Member Functions inherited from edm::EDConsumerBase
template<typename ProductType , BranchType B = InEvent>
EDGetTokenT< ProductType > consumes (edm::InputTag const &tag)
 
EDGetToken consumes (const TypeToGet &id, edm::InputTag const &tag)
 
template<BranchType B>
EDGetToken consumes (TypeToGet const &id, edm::InputTag const &tag)
 
ConsumesCollector consumesCollector ()
 Use a ConsumesCollector to gather consumes information from helper functions. More...
 
template<typename ProductType , BranchType B = InEvent>
void consumesMany ()
 
void consumesMany (const TypeToGet &id)
 
template<BranchType B>
void consumesMany (const TypeToGet &id)
 
template<typename ProductType , BranchType B = InEvent>
EDGetTokenT< ProductType > mayConsume (edm::InputTag const &tag)
 
EDGetToken mayConsume (const TypeToGet &id, edm::InputTag const &tag)
 
template<BranchType B>
EDGetToken mayConsume (const TypeToGet &id, edm::InputTag const &tag)
 

Private Member Functions

virtual void analyze (const edm::Event &, const edm::EventSetup &) override
 
virtual void beginJob () override
 
virtual void endJob () override
 
void remakeGeometry (const DisplayGeomRecord &dgRec)
 

Private Attributes

edm::Service< EveServicem_eve
 
TEveElement * m_geomList
 
edm::ESWatcher< DisplayGeomRecordm_geomWatcher
 
int m_level
 
bool m_MF
 
int m_MF_component
 
bool m_MF_isPickable
 
std::vector< double > m_MF_plane_d0
 
std::vector< double > m_MF_plane_d1
 
std::vector< double > m_MF_plane_d2
 
int m_MF_plane_draw_dir
 
int m_MF_plane_N1
 
int m_MF_plane_N2
 

Additional Inherited Members

- Public Types inherited from edm::EDAnalyzer
typedef EDAnalyzer ModuleType
 
- Static Public Member Functions inherited from edm::EDAnalyzer
static const std::string & baseType ()
 
static void fillDescriptions (ConfigurationDescriptions &descriptions)
 
static void prevalidate (ConfigurationDescriptions &)
 

Detailed Description

Definition at line 53 of file DisplayGeom.cc.

Constructor & Destructor Documentation

DisplayGeom::DisplayGeom ( const edm::ParameterSet iConfig)
explicit

Definition at line 93 of file DisplayGeom.cc.

References edm::ParameterSet::getParameter(), edm::ParameterSet::getUntrackedParameter(), m_level, m_MF, m_MF_component, m_MF_isPickable, m_MF_plane_d0, m_MF_plane_d1, m_MF_plane_d2, m_MF_plane_draw_dir, m_MF_plane_N1, m_MF_plane_N2, and AlCaHLTBitMon_QueryRunRegistry::string.

93  :
94  m_eve(),
95  m_geomList(0),
96  m_MF_component(0),
98 {
99  m_level = iConfig.getUntrackedParameter<int>( "level", 2); // Geometry level to visualize
100 
101  m_MF = iConfig.getUntrackedParameter<int>( "MF", false); // Show the MF geometry, instead of detector geometry
102 
103  std::string component = iConfig.getUntrackedParameter<std::string>("MF_component","NONE");
104  boost::algorithm::to_upper(component);
105 
106  if (component=="NONE" ){
107  m_MF_component=-1;
108  } else if (component=="ABSBZ" ){
109  m_MF_component=1;
110  } else if (component=="ABSBR" ){
111  m_MF_component=2;
112  } else if (component=="ABSBPHI" ){
113  m_MF_component=3;
114  } else if (component=="BR" ){
115  m_MF_component=4;
116  } else if (component=="BPHI" ){
117  m_MF_component=5;
118  } else { // Anything else -> |B|
119  m_MF_component=0;
120  }
121 
122  if (m_MF_component==0) {
123 
124  m_MF_plane_d0 = iConfig.getUntrackedParameter< std::vector<double> >("MF_plane_d0", std::vector<double>(3, 0.0));
125  m_MF_plane_d1 = iConfig.getParameter< std::vector<double> >("MF_plane_d1");
126  m_MF_plane_d2 = iConfig.getParameter< std::vector<double> >("MF_plane_d2");
127 
128 
129  m_MF_plane_N1 = iConfig.getUntrackedParameter<UInt_t>( "MF_plane_N", 100);
130  m_MF_plane_N2 = iConfig.getUntrackedParameter<UInt_t>( "MF_plane_N2", m_MF_plane_N1);
131 
132  m_MF_plane_draw_dir = iConfig.getUntrackedParameter<int>( "MF_plane_draw_dir", true);
133  m_MF_isPickable = iConfig.getUntrackedParameter<bool>( "MF_pickable", true);
134  }
135 }
T getParameter(std::string const &) const
T getUntrackedParameter(std::string const &, T const &) const
int m_MF_plane_N2
Definition: DisplayGeom.cc:81
void remakeGeometry(const DisplayGeomRecord &dgRec)
Definition: DisplayGeom.cc:338
int m_MF_component
Definition: DisplayGeom.cc:76
int m_MF_plane_draw_dir
Definition: DisplayGeom.cc:82
bool m_MF_isPickable
Definition: DisplayGeom.cc:83
std::vector< double > m_MF_plane_d1
Definition: DisplayGeom.cc:78
edm::Service< EveService > m_eve
Definition: DisplayGeom.cc:69
std::vector< double > m_MF_plane_d2
Definition: DisplayGeom.cc:79
std::vector< double > m_MF_plane_d0
Definition: DisplayGeom.cc:77
int m_MF_plane_N1
Definition: DisplayGeom.cc:80
edm::ESWatcher< DisplayGeomRecord > m_geomWatcher
Definition: DisplayGeom.cc:85
TEveElement * m_geomList
Definition: DisplayGeom.cc:71
DisplayGeom::~DisplayGeom ( )

Definition at line 138 of file DisplayGeom.cc.

139 {
140 }

Member Function Documentation

void DisplayGeom::analyze ( const edm::Event iEvent,
const edm::EventSetup iSetup 
)
overrideprivatevirtual

Implements edm::EDAnalyzer.

Definition at line 173 of file DisplayGeom.cc.

References EveService::AddElement(), b, edm::ESWatcher< T >::check(), funct::cos(), alignCSCRings::e, edm::EventSetup::get(), i, j, python.rootplot.utilities::ls(), m_eve, m_geomWatcher, m_MF_component, m_MF_isPickable, m_MF_plane_d0, m_MF_plane_d1, m_MF_plane_d2, m_MF_plane_draw_dir, m_MF_plane_N1, m_MF_plane_N2, PV3DBase< T, PVType, FrameType >::mag(), Min(), AlCaHLTBitMon_ParallelJobs::p, PV3DBase< T, PVType, FrameType >::phi(), lumiQueryAPI::q, funct::sin(), edmStreamStallGrapher::trans, Vector3DBase< T, FrameTag >::unit(), relativeConstraints::value, PV3DBase< T, PVType, FrameType >::x(), PV3DBase< T, PVType, FrameType >::y(), and PV3DBase< T, PVType, FrameType >::z().

174 {
175  if (m_eve)
176  {
177  // Remake geometry if it has changed.
178  m_geomWatcher.check(iSetup);
179 
180  if (m_MF_component!=-1)
181  {
183  iSetup.get<IdealMagneticFieldRecord>().get( field );
184 
185  gStyle->SetPalette(1, 0);
186 
187  int minval = 0;
188  int maxval = 4000;
189  if (m_MF_component==1){ //AbsBZ
190  minval=0, maxval=4000;
191  } else if (m_MF_component==2){ //AbsBR
192  minval=0, maxval=4000;
193  } else if (m_MF_component==3){ //AbsBphi
194  minval=0, maxval=1000;
195  } else if (m_MF_component==4){ //BR
196  minval=-4000, maxval=4000;
197  } else if (m_MF_component==5){ //Bphi
198  minval=-1000, maxval=1000;
199  }
200 
201  TEveRGBAPalette* pal = new TEveRGBAPalette(minval, maxval);
202 
203 
204  TEveStraightLineSet* ls = 0;
205  if (m_MF_plane_draw_dir) {
206  new TEveStraightLineSet("MF_line_direction");
207  ls->SetPickable(false);
208  ls->SetLineColor(kGreen);
209  ls->SetMarkerColor(kGreen);
210  ls->SetMarkerStyle(1);
211  }
212 
213  TEveQuadSet* q = new TEveQuadSet("MF_quad_values");
214  q->Reset(TEveQuadSet::kQT_RectangleXY, kFALSE, 32);
215  q->SetOwnIds(kTRUE);
216  q->SetAlwaysSecSelect(1);
217  q->SetPickable(m_MF_isPickable);
218  q->SetPalette(pal);
219 
220 
221  TEveVectorD v0(m_MF_plane_d0[0], m_MF_plane_d0[1], m_MF_plane_d0[2]);
222  TEveVectorD v01(m_MF_plane_d1[0], m_MF_plane_d1[1], m_MF_plane_d1[2]);
223  TEveVectorD v02(m_MF_plane_d2[0], m_MF_plane_d2[1], m_MF_plane_d2[2]);
224 
225  TEveVectorD b01 = (v01 -v0);
226  TEveVectorD b02 = (v02 -v0);
227  TEveVectorD b03 = b01.Cross(b02);
228 
229  TEveTrans trans;
230  trans.SetBaseVec(1, b01.fX, b01.fY, b01.fZ);
231  trans.SetBaseVec(2, b02.fX, b02.fY, b02.fZ);
232  trans.SetBaseVec(3, b03.fX, b03.fY, b03.fZ);
233  trans.SetPos(v0.Arr());
234  trans.OrtoNorm3();
235  q->SetTransMatrix(trans.Array());
236 
237  double w_step = b01.Mag()/m_MF_plane_N1;
238  double h_step = b02.Mag()/m_MF_plane_N2;
239 
240  q->SetDefWidth(w_step);
241  q->SetDefHeight(h_step);
242  TEveVectorD d1; trans.GetBaseVec(1).GetXYZ(d1); d1 *= w_step;
243  TEveVectorD d2; trans.GetBaseVec(2).GetXYZ(d2); d2 *= h_step;
244 
245  //d1.Print();
246  d2.Dump();
247  double line_step_size = TMath::Min(w_step, h_step);
248 
249  for(int i = 0; i < m_MF_plane_N1; i++)
250  {
251  for(int j=0; j <m_MF_plane_N2; j++)
252  {
253  TEveVectorD p = d1*Double_t(i) + d2*Double_t(j) + v0;
254  GlobalPoint pos(p.fX, p.fY, p.fZ);
255  GlobalVector b = field->inTesla(pos)*1000.; // in mT
256  float value = 0.;
257  if (m_MF_component==0){ //BMOD
258  value=b.mag();
259  } else if (m_MF_component==1){ //BZ
260  value = fabs(b.z());
261  } else if (m_MF_component==2){ //ABSBR
262  value = fabs(b.x()*cos(pos.phi()) + b.y()*sin(pos.phi()));
263  } else if (m_MF_component==3){ //ABSBPHI
264  value = fabs(-b.x()*sin(pos.phi()) + b.y()*cos(pos.phi()));
265  } else if (m_MF_component==2){ //BR
266  value = b.x()*cos(pos.phi()) + b.y()*sin(pos.phi());
267  } else if (m_MF_component==5){ //BPHI
268  value = -b.x()*sin(pos.phi()) + b.y()*cos(pos.phi());
269  }
270 
271  q->AddQuad(w_step*i, h_step*j);
272  q->QuadValue(value);
273  if(m_MF_isPickable) q->QuadId(new TNamed(Form("Mag (%f, %f, %f) val = %f", b.x(), b.y(), b.z(), b.mag() ), "Dong!"));
274 
275  if (ls) {
276  if (b.mag() > 1e-6) {
277  b.unit(); b *= line_step_size;
278  ls->AddLine(p.fX, p.fY, p.fZ, p.fX + b.x(),p.fY + b.y(), p.fZ + b.z());
279  }
280  else {
281  ls->AddLine(p.fX, p.fY, p.fZ, p.fX + b.x(),p.fY + b.y(), p.fZ + b.z());
282  }
283 
284  ls->AddMarker(ls->GetLinePlex().Size()-1, 0);
285  ls->AddMarker(i*m_MF_plane_N1 + j, 0);
286  }
287  }
288  }
289 
290  TEveScene* eps = gEve->SpawnNewScene("FillStyleScene");
291  gEve->GetDefaultViewer()->AddScene(eps);
292  eps->GetGLScene()->SetStyle(TGLRnrCtx::kFill);
293  eps->AddElement(q);
294  if (ls) m_eve->AddElement(ls);
295  }
296  else {
297 // // Add a test obj
298 // if (!gRandom)
299 // gRandom = new TRandom(0);
300 // TRandom& r= *gRandom;
301 
302 // Float_t s = 100;
303 
304 // TEvePointSet* ps = new TEvePointSet();
305 // ps->SetOwnIds(kTRUE);
306 // for(Int_t i = 0; i< 100; i++)
307 // {
308 // ps->SetNextPoint(r.Uniform(-s,s), r.Uniform(-s,s), r.Uniform(-s,s));
309 // ps->SetPointId(new TNamed(Form("Point %d", i), ""));
310 // }
311 
312 // ps->SetMarkerColor(TMath::Nint(r.Uniform(2, 9)));
313 // ps->SetMarkerSize(r.Uniform(1, 2));
314 // ps->SetMarkerStyle(4);
315 // m_eve->AddElement(ps);
316  }
317  }
318 }
int i
Definition: DBlmapReader.cc:9
int m_MF_plane_N2
Definition: DisplayGeom.cc:81
Sin< T >::type sin(const T &t)
Definition: Sin.h:22
T y() const
Definition: PV3DBase.h:63
int m_MF_component
Definition: DisplayGeom.cc:76
int m_MF_plane_draw_dir
Definition: DisplayGeom.cc:82
bool m_MF_isPickable
Definition: DisplayGeom.cc:83
T Min(T a, T b)
Definition: MathUtil.h:39
std::vector< double > m_MF_plane_d1
Definition: DisplayGeom.cc:78
edm::Service< EveService > m_eve
Definition: DisplayGeom.cc:69
T mag() const
Definition: PV3DBase.h:67
std::vector< double > m_MF_plane_d2
Definition: DisplayGeom.cc:79
T z() const
Definition: PV3DBase.h:64
Cos< T >::type cos(const T &t)
Definition: Cos.h:22
int j
Definition: DBlmapReader.cc:9
Vector3DBase unit() const
Definition: Vector3DBase.h:57
std::vector< double > m_MF_plane_d0
Definition: DisplayGeom.cc:77
const T & get() const
Definition: EventSetup.h:55
double b
Definition: hdecay.h:120
bool check(const edm::EventSetup &iSetup)
Definition: ESWatcher.h:57
int m_MF_plane_N1
Definition: DisplayGeom.cc:80
void AddElement(TEveElement *el)
Definition: EveService.cc:299
edm::ESWatcher< DisplayGeomRecord > m_geomWatcher
Definition: DisplayGeom.cc:85
T x() const
Definition: PV3DBase.h:62
void DisplayGeom::beginJob ( void  )
overrideprivatevirtual

Reimplemented from edm::EDAnalyzer.

Definition at line 322 of file DisplayGeom.cc.

References EveService::AddGlobalElement(), m_eve, and m_geomList.

323 {
324  if (m_eve)
325  {
326  m_geomList = new TEveElementList("Display Geom");
328  // m_eve->getManager()->GetGlobalScene()->GetGLScene()->SetStyle(TGLRnrCtx::kWireFrame);
329  }
330 }
edm::Service< EveService > m_eve
Definition: DisplayGeom.cc:69
TEveElement * m_geomList
Definition: DisplayGeom.cc:71
void AddGlobalElement(TEveElement *el)
Definition: EveService.cc:304
void DisplayGeom::endJob ( void  )
overrideprivatevirtual

Reimplemented from edm::EDAnalyzer.

Definition at line 334 of file DisplayGeom.cc.

334  {
335 }
TEveGeoTopNode * DisplayGeom::make_node ( const TString &  path,
Int_t  vis_level,
Bool_t  global_cs 
)
protected

Definition at line 147 of file DisplayGeom.cc.

References m_geomList.

Referenced by remakeGeometry().

148 {
149  if (! gGeoManager->cd(path))
150  {
151  Warning("make_node", "Path '%s' not found.", path.Data());
152  return 0;
153  }
154 
155  TEveGeoTopNode* tn = new TEveGeoTopNode(gGeoManager, gGeoManager->GetCurrentNode());
156  tn->SetVisLevel(vis_level);
157  if (global_cs)
158  {
159  tn->RefMainTrans().SetFrom(*gGeoManager->GetCurrentMatrix());
160  }
161  m_geomList->AddElement(tn);
162  gEve->AddToListTree(tn, true);
163  return tn;
164 }
tuple path
else: Piece not in the list, fine.
TEveElement * m_geomList
Definition: DisplayGeom.cc:71
void DisplayGeom::remakeGeometry ( const DisplayGeomRecord dgRec)
private

Definition at line 338 of file DisplayGeom.cc.

References relativeConstraints::geom, edm::eventsetup::EventSetupRecord::get(), m_geomList, m_level, m_MF, make_node(), and edm::ESHandle< class >::product().

339 {
340  m_geomList->DestroyElements();
341 
343  dgRec.get(geom);
344  TEveGeoManagerHolder _tgeo(const_cast<TGeoManager*>(geom.product()));
345 
346  // To have a full one, all detectors in one top-node:
347  // make_node("/cms:World_1/cms:CMSE_1", 4, kTRUE);
348 
349  if (m_MF)
350  {
351  make_node("/cms:World_1", m_level, kTRUE);
352  }
353  else
354  {
355  make_node("/cms:World_1/cms:CMSE_1/tracker:Tracker_1", m_level, kTRUE);
356  make_node("/cms:World_1/cms:CMSE_1/caloBase:CALO_1", m_level, kTRUE);
357  make_node("/cms:World_1/cms:CMSE_1/muonBase:MUON_1", m_level, kTRUE);
358  }
359 }
TEveGeoTopNode * make_node(const TString &path, Int_t vis_level, Bool_t global_cs)
Definition: DisplayGeom.cc:147
void get(HolderT &iHolder) const
T const * product() const
Definition: ESHandle.h:86
TEveElement * m_geomList
Definition: DisplayGeom.cc:71

Member Data Documentation

edm::Service<EveService> DisplayGeom::m_eve
private

Definition at line 69 of file DisplayGeom.cc.

Referenced by analyze(), and beginJob().

TEveElement* DisplayGeom::m_geomList
private

Definition at line 71 of file DisplayGeom.cc.

Referenced by beginJob(), make_node(), and remakeGeometry().

edm::ESWatcher<DisplayGeomRecord> DisplayGeom::m_geomWatcher
private

Definition at line 85 of file DisplayGeom.cc.

Referenced by analyze().

int DisplayGeom::m_level
private

Definition at line 73 of file DisplayGeom.cc.

Referenced by DisplayGeom(), and remakeGeometry().

bool DisplayGeom::m_MF
private

Definition at line 75 of file DisplayGeom.cc.

Referenced by DisplayGeom(), and remakeGeometry().

int DisplayGeom::m_MF_component
private

Definition at line 76 of file DisplayGeom.cc.

Referenced by analyze(), and DisplayGeom().

bool DisplayGeom::m_MF_isPickable
private

Definition at line 83 of file DisplayGeom.cc.

Referenced by analyze(), and DisplayGeom().

std::vector<double> DisplayGeom::m_MF_plane_d0
private

Definition at line 77 of file DisplayGeom.cc.

Referenced by analyze(), and DisplayGeom().

std::vector<double> DisplayGeom::m_MF_plane_d1
private

Definition at line 78 of file DisplayGeom.cc.

Referenced by analyze(), and DisplayGeom().

std::vector<double> DisplayGeom::m_MF_plane_d2
private

Definition at line 79 of file DisplayGeom.cc.

Referenced by analyze(), and DisplayGeom().

int DisplayGeom::m_MF_plane_draw_dir
private

Definition at line 82 of file DisplayGeom.cc.

Referenced by analyze(), and DisplayGeom().

int DisplayGeom::m_MF_plane_N1
private

Definition at line 80 of file DisplayGeom.cc.

Referenced by analyze(), and DisplayGeom().

int DisplayGeom::m_MF_plane_N2
private

Definition at line 81 of file DisplayGeom.cc.

Referenced by analyze(), and DisplayGeom().