CMS 3D CMS Logo

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 () override
 
- Public Member Functions inherited from edm::EDAnalyzer
void callWhenNewProductsRegistered (std::function< void(BranchDescription const &)> const &func)
 
 EDAnalyzer ()
 
SerialTaskQueueglobalLuminosityBlocksQueue ()
 
SerialTaskQueueglobalRunsQueue ()
 
ModuleDescription const & moduleDescription () const
 
std::string workerType () const
 
 ~EDAnalyzer () override
 
- Public Member Functions inherited from edm::EDConsumerBase
std::vector< ConsumesInfoconsumesInfo () const
 
void convertCurrentProcessAlias (std::string const &processName)
 Convert "@currentProcess" in InputTag process names to the actual current process name. More...
 
 EDConsumerBase ()
 
 EDConsumerBase (EDConsumerBase const &)=delete
 
 EDConsumerBase (EDConsumerBase &&)=default
 
ESProxyIndex const * esGetTokenIndices (edm::Transition iTrans) const
 
ProductResolverIndexAndSkipBit indexFrom (EDGetToken, BranchType, TypeID const &) const
 
void itemsMayGet (BranchType, std::vector< ProductResolverIndexAndSkipBit > &) const
 
void itemsToGet (BranchType, std::vector< ProductResolverIndexAndSkipBit > &) const
 
std::vector< ProductResolverIndexAndSkipBit > const & itemsToGetFrom (BranchType iType) const
 
void labelsForToken (EDGetToken iToken, Labels &oLabels) const
 
void modulesWhoseProductsAreConsumed (std::vector< ModuleDescription const * > &modules, ProductRegistry const &preg, std::map< std::string, ModuleDescription const * > const &labelsToDesc, std::string const &processName) const
 
EDConsumerBase const & operator= (EDConsumerBase const &)=delete
 
EDConsumerBaseoperator= (EDConsumerBase &&)=default
 
bool registeredToConsume (ProductResolverIndex, bool, BranchType) const
 
bool registeredToConsumeMany (TypeID const &, BranchType) const
 
ProductResolverIndexAndSkipBit uncheckedIndexFrom (EDGetToken) const
 
void updateLookup (BranchType iBranchType, ProductResolverIndexHelper const &, bool iPrefetchMayGet)
 
void updateLookup (eventsetup::ESRecordsToProxyIndices const &)
 
virtual ~EDConsumerBase () noexcept(false)
 

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 ESProduct , typename ESRecord , Transition Tr = Transition::Event>
auto esConsumes ()
 
template<typename ESProduct , typename ESRecord , Transition Tr = Transition::Event>
auto esConsumes (ESInputTag const &tag)
 
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

void analyze (const edm::Event &, const edm::EventSetup &) override
 
void beginJob () override
 
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
 
- Public Types inherited from edm::EDConsumerBase
typedef ProductLabels Labels
 
- Static Public Member Functions inherited from edm::EDAnalyzer
static const std::string & baseType ()
 
static void fillDescriptions (ConfigurationDescriptions &descriptions)
 
static void prevalidate (ConfigurationDescriptions &)
 
static bool wantsGlobalLuminosityBlocks ()
 
static bool wantsGlobalRuns ()
 
static bool wantsStreamLuminosityBlocks ()
 
static bool wantsStreamRuns ()
 

Detailed Description

Definition at line 53 of file DisplayGeom.cc.

Constructor & Destructor Documentation

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

Definition at line 90 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.

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

Definition at line 128 of file DisplayGeom.cc.

128 {}

Member Function Documentation

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

Definition at line 154 of file DisplayGeom.cc.

References EveService::AddElement(), b, edm::ESWatcher< T >::check(), funct::cos(), MillePedeFileConverter_cfg::e, edm::EventSetup::get(), mps_fire::i, MagneticField::inTesla(), dqmiolumiharvest::j, eostools::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(), data-class-funcs::q, funct::sin(), Vector3DBase< T, FrameTag >::unit(), V0Monitor_cff::v0, PV3DBase< T, PVType, FrameType >::x(), PV3DBase< T, PVType, FrameType >::y(), and PV3DBase< T, PVType, FrameType >::z().

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

Reimplemented from edm::EDAnalyzer.

Definition at line 300 of file DisplayGeom.cc.

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

300  {
301  if (m_eve) {
302  m_geomList = new TEveElementList("Display Geom");
304  // m_eve->getManager()->GetGlobalScene()->GetGLScene()->SetStyle(TGLRnrCtx::kWireFrame);
305  }
306 }
edm::Service< EveService > m_eve
Definition: DisplayGeom.cc:67
TEveElement * m_geomList
Definition: DisplayGeom.cc:69
void AddGlobalElement(TEveElement *el)
Definition: EveService.cc:263
void DisplayGeom::endJob ( void  )
overrideprivatevirtual

Reimplemented from edm::EDAnalyzer.

Definition at line 309 of file DisplayGeom.cc.

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

Definition at line 134 of file DisplayGeom.cc.

References m_geomList.

Referenced by remakeGeometry().

134  {
135  if (!gGeoManager->cd(path)) {
136  Warning("make_node", "Path '%s' not found.", path.Data());
137  return nullptr;
138  }
139 
140  TEveGeoTopNode* tn = new TEveGeoTopNode(gGeoManager, gGeoManager->GetCurrentNode());
141  tn->SetVisLevel(vis_level);
142  if (global_cs) {
143  tn->RefMainTrans().SetFrom(*gGeoManager->GetCurrentMatrix());
144  }
145  m_geomList->AddElement(tn);
146  gEve->AddToListTree(tn, true);
147  return tn;
148 }
TEveElement * m_geomList
Definition: DisplayGeom.cc:69
void DisplayGeom::remakeGeometry ( const DisplayGeomRecord dgRec)
private

Definition at line 312 of file DisplayGeom.cc.

References relativeConstraints::geom, edm::eventsetup::DependentRecordImplementation< RecordT, ListT >::get(), m_geomList, m_level, m_MF, make_node(), and edm::ESHandle< T >::product().

312  {
313  m_geomList->DestroyElements();
314 
316  dgRec.get(geom);
317  TEveGeoManagerHolder _tgeo(const_cast<TGeoManager*>(geom.product()));
318 
319  // To have a full one, all detectors in one top-node:
320  // make_node("/cms:World_1/cms:CMSE_1", 4, kTRUE);
321 
322  if (m_MF) {
323  make_node("/cms:World_1", m_level, kTRUE);
324  } else {
325  make_node("/cms:World_1/cms:CMSE_1/tracker:Tracker_1", m_level, kTRUE);
326  make_node("/cms:World_1/cms:CMSE_1/caloBase:CALO_1", m_level, kTRUE);
327  make_node("/cms:World_1/cms:CMSE_1/muonBase:MUON_1", m_level, kTRUE);
328  }
329 }
TEveGeoTopNode * make_node(const TString &path, Int_t vis_level, Bool_t global_cs)
Definition: DisplayGeom.cc:134
ProductT const & get(ESGetToken< ProductT, DepRecordT > const &iToken) const
T const * product() const
Definition: ESHandle.h:86
TEveElement * m_geomList
Definition: DisplayGeom.cc:69

Member Data Documentation

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

Definition at line 67 of file DisplayGeom.cc.

Referenced by analyze(), and beginJob().

TEveElement* DisplayGeom::m_geomList
private

Definition at line 69 of file DisplayGeom.cc.

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

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

Definition at line 83 of file DisplayGeom.cc.

Referenced by analyze().

int DisplayGeom::m_level
private

Definition at line 71 of file DisplayGeom.cc.

Referenced by DisplayGeom(), and remakeGeometry().

bool DisplayGeom::m_MF
private

Definition at line 73 of file DisplayGeom.cc.

Referenced by DisplayGeom(), and remakeGeometry().

int DisplayGeom::m_MF_component
private

Definition at line 74 of file DisplayGeom.cc.

Referenced by analyze(), and DisplayGeom().

bool DisplayGeom::m_MF_isPickable
private

Definition at line 81 of file DisplayGeom.cc.

Referenced by analyze(), and DisplayGeom().

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

Definition at line 75 of file DisplayGeom.cc.

Referenced by analyze(), and DisplayGeom().

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

Definition at line 76 of file DisplayGeom.cc.

Referenced by analyze(), and DisplayGeom().

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

Definition at line 77 of file DisplayGeom.cc.

Referenced by analyze(), and DisplayGeom().

int DisplayGeom::m_MF_plane_draw_dir
private

Definition at line 80 of file DisplayGeom.cc.

Referenced by analyze(), and DisplayGeom().

int DisplayGeom::m_MF_plane_N1
private

Definition at line 78 of file DisplayGeom.cc.

Referenced by analyze(), and DisplayGeom().

int DisplayGeom::m_MF_plane_N2
private

Definition at line 79 of file DisplayGeom.cc.

Referenced by analyze(), and DisplayGeom().