00001
00002
00003 #include "VisReco/VisMuonCSC/interface/VisCSCWireDigiTwig.h"
00004 #include "VisReco/VisMuonCSC/interface/VisCSCDigiTools.h"
00005 #include "VisReco/VisMuonCSC/interface/VisCSCChamberDrawer.h"
00006 #include "VisFramework/VisFrameworkBase/interface/VisTwigFactroyService.h"
00007 #include "VisFramework/VisFrameworkBase/interface/VisEventSelector.h"
00008 #include "VisFramework/VisFrameworkBase/interface/debug.h"
00009 #include "DataFormats/CSCDigi/interface/CSCWireDigi.h"
00010 #include "DataFormats/CSCDigi/interface/CSCWireDigiCollection.h"
00011 #include "FWCore/Framework/interface/Event.h"
00012 #include "FWCore/Framework/interface/EventSetup.h"
00013 #include "Geometry/CommonDetUnit/interface/GeomDetType.h"
00014 #include "Geometry/CommonDetUnit/interface/GeomDetUnit.h"
00015 #include "Geometry/Records/interface/MuonGeometryRecord.h"
00016 #include "Geometry/CSCGeometry/interface/CSCLayer.h"
00017 #include "Geometry/CSCGeometry/interface/CSCLayerGeometry.h"
00018 #include "DataFormats/GeometryVector/interface/GlobalPoint.h"
00019 #include "Iguana/Models/interface/IgTextRep.h"
00020 #include "Iguana/GLModels/interface/Ig3DRep.h"
00021 #include "Iguana/GLModels/interface/IgLegoRep.h"
00022 #include "Iguana/GLModels/interface/IgRPhiRep.h"
00023 #include "Iguana/GLModels/interface/IgRZRep.h"
00024 #include "Iguana/GLModels/interface/IgSpareRep.h"
00025 #include "Iguana/Inventor/interface/IgSoTower.h"
00026 #include "Iguana/Studio/interface/IgQtLock.h"
00027 #include <Inventor/nodes/SoDrawStyle.h>
00028 #include <Inventor/nodes/SoMaterial.h>
00029 #include <Inventor/nodes/SoSeparator.h>
00030 #include <Inventor/nodes/SoCube.h>
00031 #include <Inventor/nodes/SoLineSet.h>
00032 #include <Inventor/nodes/SoTranslation.h>
00033 #include <Inventor/nodes/SoPointSet.h>
00034 #include <Inventor/nodes/SoTransform.h>
00035 #include <Inventor/nodes/SoRotation.h>
00036 #include <Inventor/nodes/SoText3.h>
00037 #include <Inventor/nodes/SoFont.h>
00038 #include <classlib/utils/DebugAids.h>
00039 #include <qstring.h>
00040 #include <iostream>
00041 #include <iomanip>
00042
00043
00044
00045
00046
00047
00048
00049
00050
00051 namespace
00052 {
00053 VisQueuedTwig *
00054 createThisTwig (IgState *state, IgTwig *parent,
00055 const std::string &name,
00056 const std::string &friendlyName,
00057 const std::string &modLabel,
00058 const std::string &instanceName,
00059 const std::string &processName)
00060 {
00061 return new VisCSCWireDigiTwig (state, parent, "Wire digis (" + name + ")",
00062 friendlyName, modLabel, instanceName, processName);
00063 }
00064 }
00065
00066
00067
00068
00069 VisCSCWireDigiTwig::VisCSCWireDigiTwig (IgState *state, IgTwig *parent,
00070 const std::string &name ,
00071 const std::string &friendlyName ,
00072 const std::string &moduleLabel ,
00073 const std::string &instanceName ,
00074 const std::string &processName )
00075 : VisQueuedTwig (state, parent, name),
00076 m_text (name),
00077 m_friendlyName (friendlyName),
00078 m_moduleLabel (moduleLabel),
00079 m_instanceName (instanceName),
00080 m_processName (processName)
00081 {
00082 VisTwigFactroyService *tfService = VisTwigFactroyService::get (state);
00083 if (! tfService)
00084 {
00085 tfService = new VisTwigFactroyService (state);
00086 }
00087 edm::TypeID caloJetsID (typeid (CSCWireDigiCollection));
00088 tfService->registerTwig (caloJetsID.friendlyClassName (), &createThisTwig);
00089 }
00090
00091 void
00092 VisCSCWireDigiTwig::onNewEvent (const edm::Event &event,
00093 const edm::EventSetup &eventSetup)
00094 {
00095
00096 VisQueuedTwig::onNewEvent (event, eventSetup);
00097
00098 m_digis.clear ();
00099 m_text = (QString ("Run # %1, event # %2")
00100 .arg (event.id ().run ())
00101 .arg (event.id ().event ()).latin1 ());
00102
00103 std::vector<edm::Handle<CSCWireDigiCollection> > digiCollections;
00104
00105 try
00106 {
00107 if ((! m_friendlyName.empty ()) || (! m_moduleLabel.empty ()) || (! m_instanceName.empty ()) || (! m_processName.empty ()))
00108 {
00109 VisEventSelector visSel (m_friendlyName, m_moduleLabel, m_instanceName, m_processName);
00110 event.getMany (visSel, digiCollections);
00111 }
00112 else
00113 {
00114 event.getManyByType (digiCollections);
00115 }
00116
00117 eventSetup.get<MuonGeometryRecord> ().get (m_pDD);
00118 }
00119 catch (cms::Exception& e)
00120 {
00121 if (this->m_onCmsException)
00122 this->m_onCmsException (&e);
00123 }
00124 catch (lat::Error &e)
00125 {
00126 if (this->m_onError)
00127 this->m_onError (&e);
00128 }
00129 catch (std::exception &e)
00130 {
00131 if (this->m_onException)
00132 this->m_onException (&e);
00133 }
00134 catch (...)
00135 {
00136 if (this->m_onUnhandledException)
00137 this->m_onUnhandledException ();
00138 }
00139
00140 if (! digiCollections.empty ())
00141 {
00142 std::vector<edm::Handle<CSCWireDigiCollection> >::iterator i;
00143 std::vector<edm::Handle<CSCWireDigiCollection> >::iterator iEnd;
00144 for (i = digiCollections.begin (), iEnd = digiCollections.end (); i != iEnd; ++i)
00145 {
00146 const CSCWireDigiCollection& c = *(*i);
00147
00148
00149 CSCWireDigiCollection::DigiRangeIterator detUnitIt;
00150 CSCWireDigiCollection::DigiRangeIterator detUnitItEnd;
00151 for (detUnitIt = c.begin (), detUnitItEnd = c.end (); detUnitIt != detUnitItEnd; ++detUnitIt)
00152 {
00153 const CSCDetId &id = (*detUnitIt).first;
00154 const CSCWireDigiCollection::Range &range = (*detUnitIt).second;
00155
00156
00157 for (CSCWireDigiCollection::const_iterator digiIt = range.first;
00158 digiIt != range.second;
00159 ++digiIt)
00160 {
00161 std::pair< CSCDetId, CSCWireDigi > p;
00162 p.first = id;
00163 p.second = (*digiIt);
00164 m_digis.push_back (p);
00165
00166 }
00167 }
00168 }
00169 }
00170
00171 VisQueuedTwig::onBaseInvalidate ();
00172 }
00173
00174 void
00175 VisCSCWireDigiTwig::update (IgTextRep *rep)
00176 {
00177
00178 VisQueuedTwig::update (rep);
00179
00180
00181 std::ostringstream text;
00182 text << "Total " << m_digis.size () << " CSC wire digis: " << m_text << "<br>";
00183
00184 text << "<table width='100%' border=1>"
00185 << "<TR align = center>"
00186 << "<TH>Number</TH>"
00187 << "<TH>Position</TH>"
00188 << "<TH>Wire group</TH>"
00189 << "<TH>Beam-crossing tag</TH>"
00190 << "<TH>Time bin</TH>"
00191 << "</TR>";
00192 text << setiosflags (std::ios::showpoint | std::ios::fixed);
00193 text.setf (std::ios::right, std::ios::adjustfield);
00194
00195 if ( ! m_digis.empty () )
00196 {
00197
00198 int nDigis = 0;
00199 try
00200 {
00201 for (std::vector<std::pair<CSCDetId, CSCWireDigi> >::const_iterator i = m_digis.begin (), iEnd = m_digis.end (); i != iEnd; ++i)
00202 {
00203 Surface::GlobalPoint pos( NAN, NAN, NAN );
00204 if (m_pDD.isValid ()) pos = (m_pDD->idToDet ((*i).first))->surface ().position ();
00205 text << "<TR align = right>"
00206 << "<TD>" << std::setw (3) << ++nDigis << "</TD>"
00207 << "<TD>" << pos.x () << ", " << pos.y () << ", " << pos.z () << "</TD>"
00208 << "<TD>" << std::setw (5) << std::setprecision (3) << (*i).second.getWireGroup () << "</TD>"
00209 << "<TD>" << std::setw (5) << std::setprecision (3) << (*i).second.getBeamCrossingTag () << "</TD>"
00210 << "<TD>" << std::setw (6) << std::setprecision (3) << (*i).second.getTimeBin () << "</TD>"
00211 << "</TR>";
00212 }
00213 }
00214 catch (cms::Exception& e)
00215 {
00216 if (this->m_onCmsException)
00217 this->m_onCmsException (&e);
00218 }
00219 catch (lat::Error &e)
00220 {
00221 if (this->m_onError)
00222 this->m_onError (&e);
00223 }
00224 catch (std::exception &e)
00225 {
00226 if (this->m_onException)
00227 this->m_onException (&e);
00228 }
00229 catch (...)
00230 {
00231 if (this->m_onUnhandledException)
00232 this->m_onUnhandledException ();
00233 }
00234 }
00235 text << "</table>";
00236
00237
00238 IgQtLock ();
00239 rep->setText (text.str ());
00240 }
00241
00242 void
00243 VisCSCWireDigiTwig::update (Ig3DRep *rep)
00244 {
00245
00246 VisQueuedTwig::update (rep);
00247
00248 IgQtLock ();
00249 rep->clear ();
00250 m_dets.clear ();
00251
00252 if (! m_digis.empty () && m_pDD.isValid ())
00253 {
00254 VisCSCChamberDrawer d;
00255 const float width= 0.02;
00256 const float depth = 0.01;
00257
00258
00259 SoDrawStyle *drawStyle = new SoDrawStyle;
00260 drawStyle->pointSize = 5.0;
00261
00262 SoSeparator *sep = new SoSeparator;
00263 sep->addChild (drawStyle);
00264
00265 try
00266 {
00267 SoMaterial *matl = new SoMaterial;
00268 matl->diffuseColor.setValue (0.5, 0.0, 1.0);
00269 matl->emissiveColor.setValue(0.5, 0.0, 1.0);
00270 matl->shininess = 1.;
00271
00272 SoDrawStyle *drawStylel = new SoDrawStyle;
00273 drawStylel->pointSize = 1.;
00274
00275 SoSeparator *pulses = new SoSeparator;
00276 pulses->addChild (matl);
00277 pulses->addChild (drawStylel);
00278
00279 for (std::vector<std::pair<CSCDetId, CSCWireDigi> >::const_iterator
00280 i = m_digis.begin (), iEnd = m_digis.end (); i != iEnd; ++i)
00281 {
00282 const CSCDetId& id = (*i).first;
00283 if (m_dets.find(id) == m_dets.end() )
00284 {
00285 m_dets.insert(id);
00286
00287 d.getOutline(sep, m_pDD, id);
00288
00289 }
00290
00291 const CSCLayer *layer_p = m_pDD->layer (id);
00292 const CSCLayerGeometry *layerGeom = layer_p->geometry ();
00293 const int wireGroup_id = ((*i).second).getWireGroup ();
00294 const LocalPoint centerWireGroup = layerGeom->localCenterOfWireGroup (wireGroup_id);
00295 const Surface::GlobalPoint pos = (m_pDD->idToDet (id))->surface ().toGlobal (centerWireGroup);
00296 SbVec3f pt( pos.x(), pos.y(), pos.z() );
00297 pt *= 0.01F;
00298
00299 SoTranslation *inc = new SoTranslation;
00300 inc->translation = pt;
00301
00302 SbVec3f axis (0., 0., 1.);
00303 float angle = -atan (pt[0] / pt[1]) - M_PI / 2;
00304 SbRotation r (axis, angle);
00305
00306 SoTransform *xform = new SoTransform;
00307 xform ->rotation = r;
00308
00309 SoCube *hit = new SoCube;
00310 hit->width = width;
00311 hit->height = layerGeom->lengthOfWireGroup (wireGroup_id) / 100.;
00312 hit->depth = depth;
00313
00314 SoSeparator *pulse = new SoSeparator;
00315 pulse->addChild (inc);
00316 pulse->addChild (xform);
00317 pulse->addChild (hit);
00318 pulses->addChild (pulse);
00319
00320 sep->addChild (pulses);
00321 }
00322 }
00323 catch (cms::Exception& e)
00324 {
00325 if (this->m_onCmsException)
00326 this->m_onCmsException (&e);
00327 }
00328 catch (lat::Error &e)
00329 {
00330 if (this->m_onError)
00331 this->m_onError (&e);
00332 }
00333 catch (std::exception &e)
00334 {
00335 if (this->m_onException)
00336 this->m_onException (&e);
00337 }
00338 catch (...)
00339 {
00340 if (this->m_onUnhandledException)
00341 this->m_onUnhandledException ();
00342 }
00343 rep->node ()->addChild (sep);
00344 }
00345 }
00346
00347 void
00348 VisCSCWireDigiTwig::update (IgLegoRep *rep)
00349 {
00350
00351 VisQueuedTwig::update (rep);
00352
00353 IgQtLock ();
00354 rep->clear ();
00355
00356
00357
00358
00359
00360
00361
00362
00363
00364
00365
00366
00367
00368
00369
00370
00371
00372
00373
00374
00375
00376
00377
00378
00379
00380
00381
00382
00383
00384
00385
00386
00387
00388
00389
00390
00391
00392
00393
00394
00395
00396
00397
00398
00399
00400
00401
00402
00403
00404
00405
00406
00407
00408
00409
00410
00411 }
00412
00413 void
00414 VisCSCWireDigiTwig::update (IgRPhiRep *rep)
00415 {
00416
00417 VisQueuedTwig::update (rep);
00418
00419 IgQtLock ();
00420 rep->clear ();
00421
00422 if (! m_digis.empty () && m_pDD.isValid ())
00423 {
00424 const float width= 0.02;
00425 const float depth = 0.01;
00426
00427 SbColor grey35;
00428 float transparency = 0.0f;
00429 grey35.setPackedValue(static_cast<uint32_t>(0x00595959), transparency);
00430 SoMaterial *mat = new SoMaterial;
00431 mat->diffuseColor.setValue (grey35);
00432 mat->emissiveColor.setValue(grey35);
00433
00434 SoDrawStyle *drawStyle = new SoDrawStyle;
00435 drawStyle->pointSize = 5.0;
00436
00437 SoSeparator *sep = new SoSeparator;
00438 sep->addChild (mat);
00439 sep->addChild (drawStyle);
00440
00441 try
00442 {
00443 SoMaterial *matl = new SoMaterial;
00444 matl->diffuseColor.setValue (0.5, 0.0, 1.0);
00445 matl->emissiveColor.setValue(0.5, 0.0, 1.0);
00446 matl->shininess = 1.;
00447
00448 SoDrawStyle *drawStylel = new SoDrawStyle;
00449 drawStylel->pointSize = 1.;
00450
00451 SoSeparator *pulses = new SoSeparator;
00452 pulses->addChild (matl);
00453 pulses->addChild (drawStylel);
00454
00455 SoVertexProperty *vertices = new SoVertexProperty;
00456 int nVrtx = 0;
00457 for (std::vector<std::pair<CSCDetId, CSCWireDigi> >::const_iterator
00458 i = m_digis.begin (), iEnd = m_digis.end (); i != iEnd; ++i)
00459 {
00460 const CSCDetId& id = (*i).first;
00461
00462 Surface::GlobalPoint pos = (m_pDD->idToDet (id))->surface ().position ();
00463 float x = pos.x () / 100.0;
00464 float y = pos.y () / 100.0;
00465 float z = pos.z () / 100.0;
00466 vertices->vertex.set1Value (nVrtx++, SbVec3f (x, y, z));
00467
00468 const CSCLayer* layer_p = m_pDD->layer(id);
00469 const CSCLayerGeometry* layerGeom=0;
00470 if (layer_p)
00471 {
00472 layerGeom = layer_p->geometry ();
00473 }
00474 else
00475 {
00476
00477 }
00478
00479 bool framePlot = true;
00480 if (framePlot)
00481 {
00482 const std::vector<float> trapezBounds = layerGeom->parameters ();
00483 std::vector<Surface::GlobalPoint> CrossPoint;
00484 CrossPoint.push_back ((m_pDD->idToDet (id))->surface ().toGlobal
00485 (LocalPoint (-trapezBounds [0], -trapezBounds [3], 0.)));
00486 CrossPoint.push_back ((m_pDD->idToDet (id))->surface ().toGlobal
00487 (LocalPoint (trapezBounds [0], -trapezBounds [3], 0.)));
00488 CrossPoint.push_back ((m_pDD->idToDet (id))->surface ().toGlobal
00489 (LocalPoint(trapezBounds [1], trapezBounds [3], 0.)));
00490 CrossPoint.push_back ((m_pDD->idToDet (id))->surface ().toGlobal
00491 (LocalPoint (-trapezBounds [1], trapezBounds [3], 0.)));
00492
00493 SoVertexProperty *vert = new SoVertexProperty;
00494 int nVrx = 0;
00495 for (std::vector<Surface::GlobalPoint>::iterator _crossP = CrossPoint.begin (); _crossP != CrossPoint.end (); ++_crossP)
00496 {
00497 x = _crossP->x () / 100.0;
00498 y = _crossP->y () / 100.0;
00499 z = _crossP->z () / 100.0;
00500 vert->vertex.set1Value (nVrx++, SbVec3f (x, y, z));
00501 }
00502 std::vector<Surface::GlobalPoint>::reference closeCircle
00503 = CrossPoint.front ();
00504 x = closeCircle.x () / 100.0;
00505 y = closeCircle.y () / 100.0;
00506 z = closeCircle.z () / 100.0;
00507 vert->vertex.set1Value (nVrx++, SbVec3f (x, y, 0.f));
00508
00509 vert->vertex.setNum (nVrx);
00510 SoLineSet *trapez = new SoLineSet;
00511 trapez->vertexProperty.setValue (vert);
00512 trapez->numVertices [CrossPoint.size () + 1];
00513
00514 SoMaterial *mats = new SoMaterial;
00515 mats->diffuseColor.setValue (1.0, 1.0, 1.0);
00516 mats->emissiveColor.setValue (1.0, 1.0, 1.0);
00517
00518 SoSeparator *shape = new SoSeparator;
00519 shape->addChild (mats);
00520 shape->addChild (trapez);
00521
00522 sep->addChild (shape);
00523 }
00524
00525 int wireGroup_id = ((*i).second).getWireGroup ();
00526 LocalPoint centerWireGroup = layerGeom->localCenterOfWireGroup (wireGroup_id);
00527 pos = (m_pDD->idToDet (id))->surface ().toGlobal (centerWireGroup);
00528 x = pos.x () / 100.0;
00529 y = pos.y () / 100.0;
00530 z = pos.z () / 100.0;
00531
00532 SoTranslation *inc = new SoTranslation;
00533 inc->translation = SbVec3f (x, y, z);
00534
00535 SbVec3f axis (0., 0., 1.);
00536 float angle = -atan (x / y) - M_PI / 2;
00537 SbRotation r (axis, angle);
00538
00539 SoTransform *xform = new SoTransform;
00540 xform ->rotation = r;
00541
00542 SoCube *hit = new SoCube;
00543 hit->width = width;
00544 hit->height = layerGeom->lengthOfWireGroup (wireGroup_id) / 100.;
00545 hit->depth = depth;
00546
00547 SoSeparator *pulse = new SoSeparator;
00548 pulse->addChild (inc);
00549 pulse->addChild (xform);
00550 pulse->addChild (hit);
00551 pulses->addChild (pulse);
00552
00553 sep->addChild (pulses);
00554 }
00555
00556 vertices->vertex.setNum (m_digis.size ());
00557 SoPointSet *points = new SoPointSet;
00558 points->vertexProperty.setValue (vertices);
00559 points->numPoints.setValue (m_digis.size ());
00560
00561 sep->addChild (points);
00562 }
00563 catch (cms::Exception& e)
00564 {
00565 if (this->m_onCmsException)
00566 this->m_onCmsException (&e);
00567 }
00568 catch (lat::Error &e)
00569 {
00570 if (this->m_onError)
00571 this->m_onError (&e);
00572 }
00573 catch (std::exception &e)
00574 {
00575 if (this->m_onException)
00576 this->m_onException (&e);
00577 }
00578 catch (...)
00579 {
00580 if (this->m_onUnhandledException)
00581 this->m_onUnhandledException ();
00582 }
00583 rep->node ()->addChild (sep);
00584 }
00585 }
00586
00587 void
00588 VisCSCWireDigiTwig::update (IgSpareRep *rep)
00589 {
00590
00591 VisQueuedTwig::update (rep);
00592
00593 IgQtLock ();
00594 rep->clear ();
00595
00596 if (! m_digis.empty () && m_pDD.isValid ())
00597 {
00598 SoSeparator *sep = new SoSeparator;
00599
00600 SoMaterial *mat = new SoMaterial;
00601 mat->diffuseColor.setValue (0.0, 0.0, 0.0);
00602 sep->addChild (mat);
00603 try
00604 {
00605 bool iterations = false;
00606 float OurPhi = 9999999.;
00607 float OurPhiSlice = 9999999.;
00608 float OurZ = 99999999.;
00609 for (std::vector<std::pair<CSCDetId, CSCWireDigi> >::const_iterator i =
00610 m_digis.begin (); i != m_digis.end (); ++i)
00611 {
00612 const CSCDetId& id = (*i).first;
00613
00614
00615
00616
00617 const CSCLayer* layer_p = m_pDD->layer(id);
00618 const CSCLayerGeometry* layerGeom=0;
00619
00620 if(layer_p){
00621 layerGeom = layer_p->geometry();
00622 }
00623 else{
00624 }
00625
00626 Surface::GlobalPoint pos = (m_pDD->idToDet (id))->surface ().position ();
00627 float layer_x = pos.x () / 100.0;
00628 float layer_y = pos.y () / 100.0;
00629 float layer_z = pos.z () / 100.0;
00630 float layer_phi = pos.phi ();
00631 float layer_r = sqrt(layer_x*layer_x + layer_y*layer_y);
00632 if(!iterations){
00633
00634 iterations=VisCaptions(layer_z, layer_phi, OurPhi, OurZ, sep);
00635 }
00636 const std::vector<float> trapezBounds = layerGeom->parameters();
00637 OurPhiSlice = 2. * atan(trapezBounds[1]/(layer_r + trapezBounds[3])) * 0.8;
00638
00639 if (fabs(layer_phi - OurPhi) < 2. * OurPhiSlice){
00640 int wireGroup_id = ((*i).second).getWireGroup();
00641 LocalPoint centerWireGroup=layerGeom->localCenterOfWireGroup(wireGroup_id);
00642 float wireLength = layerGeom->lengthOfWireGroup(wireGroup_id);
00643
00644 SoLineSet *trapez = new SoLineSet;
00645 SoLineSet *rect_s = new SoLineSet;
00646 SoLineSet *rect_w = new SoLineSet;
00647
00648
00649 SoTranslation *trans = new SoTranslation;
00650 SoTranslation *trans_caption = new SoTranslation;
00651 SoTranslation *trans_s = new SoTranslation;
00652 SoTranslation *trans_w = new SoTranslation;
00653
00654
00655
00656
00657
00658
00659
00660 SoText3 *TextCaption = new SoText3;
00661 char ch[10];
00662 sprintf( ch,"%1.1f", layer_phi);
00663 TextCaption->string = ch;
00664
00665 SoFont *font_caption = new SoFont;
00666 font_caption->name.setValue(VisFont);
00667 font_caption->size.setValue(VisFontSize);
00668
00669 SoVertexProperty *vert = new SoVertexProperty;
00670 int nVrx = 0;
00671 float x = (centerWireGroup.x()-wireLength/2.)/100.;
00672 float y = centerWireGroup.y()/100.;
00673 float z = 0.;
00674 vert->vertex.set1Value (nVrx++,SbVec3f (x, y, z) );
00675
00676 x = (centerWireGroup.x()+wireLength/2.)/100.;
00677 y = centerWireGroup.y()/100.;
00678 z = 0.;
00679 vert->vertex.set1Value (nVrx++,SbVec3f (x, y, z) );
00680
00681 vert->vertex.setNum (nVrx);
00682 SoLineSet *WireGroupVis = new SoLineSet;
00683 WireGroupVis->vertexProperty.setValue (vert);
00684 WireGroupVis->numVertices[2];
00685
00686 SoVertexProperty *wireDots = new SoVertexProperty;
00687 nVrx = 0;
00688 x = centerWireGroup.y()/ 100.0;
00689 y = (trapezBounds[2]*1.1 - id.layer()*2.*trapezBounds[2]/6.)/4.;
00690 z = 0. / 100.0;
00691
00692 if(3==id.station()) y=-y;
00693
00694 wireDots->vertex.set1Value (nVrx++, SbVec3f (x, y, z));
00695 wireDots->vertex.setNum (nVrx);
00696 int Npoints=nVrx;
00697
00698 SoMaterial *matw = new SoMaterial;
00699 SoMaterial *matf = new SoMaterial;
00700 if(OurPhi == layer_phi){
00701 matw->diffuseColor.setValue (0.3, 0.0, 0.3);
00702 matf->diffuseColor.setValue (0.0, 0.0, 0.0);
00703 }
00704 else{
00705 matw->diffuseColor.setValue (0.6, 0.0, 6.0);
00706 matf->diffuseColor.setValue(0.6, 0.6, 0.6);
00707 }
00708
00709 SoSeparator *shape = new SoSeparator;
00710 shape->addChild (matf);
00711 shape->addChild (trapez);
00712
00713 SoSeparator *caption = new SoSeparator;
00714 caption->addChild (matf);
00715 caption->addChild (trans_caption);
00716 caption->addChild (font_caption);
00717 caption->addChild (TextCaption);
00718
00719 SoSeparator *proj_s = new SoSeparator;
00720 proj_s->addChild (matf);
00721 proj_s->addChild (trans_s);
00722 proj_s->addChild (rect_s);
00723
00724 SoSeparator *proj_w = new SoSeparator;
00725 proj_w->addChild (matf);
00726 proj_w->addChild (trans_w);
00727 proj_w->addChild (rect_w);
00728
00729 SoDrawStyle *drawStylel = new SoDrawStyle;
00730 drawStylel->pointSize = 2.0;
00731
00732 SoSeparator *dotsWG = new SoSeparator;
00733 SoPointSet *points = new SoPointSet;
00734 points->vertexProperty.setValue (wireDots);
00735 points->numPoints.setValue (Npoints);
00736 dotsWG->addChild (matw);
00737 dotsWG->addChild (drawStylel);
00738 dotsWG->addChild (trans_w);
00739 dotsWG->addChild (points);
00740
00741 SoSeparator *wiregroup = new SoSeparator;
00742 wiregroup->addChild (matw);
00743 wiregroup->addChild (WireGroupVis);
00744
00745 SoSeparator *layer = new SoSeparator;
00746 layer->addChild (trans);
00747 layer->addChild (shape);
00748 layer->addChild (wiregroup);
00749
00750 sep->addChild (layer);
00751 sep->addChild (caption);
00752 sep->addChild (proj_s);
00753 sep->addChild (proj_w);
00754 sep->addChild (dotsWG);
00755 }
00756 }
00757 }
00758 catch (cms::Exception& e)
00759 {
00760 if (this->m_onCmsException)
00761 this->m_onCmsException (&e);
00762 }
00763 catch (lat::Error &e)
00764 {
00765 if (this->m_onError)
00766 this->m_onError (&e);
00767 }
00768 catch (std::exception &e)
00769 {
00770 if (this->m_onException)
00771 this->m_onException (&e);
00772 }
00773 catch (...)
00774 {
00775 if (this->m_onUnhandledException)
00776 this->m_onUnhandledException ();
00777 }
00778
00779
00780 rep->node ()->addChild (sep);
00781 }
00782 }
00783
00784 void
00785 VisCSCWireDigiTwig::update (IgRZRep *rep)
00786 {
00787
00788 VisQueuedTwig::update (rep);
00789
00790 IgQtLock ();
00791 rep->clear ();
00792
00793 if (! m_digis.empty () && m_pDD.isValid ())
00794 {
00795 SoSeparator *sep = new SoSeparator;
00796 SoMaterial *mat = new SoMaterial;
00797 mat->diffuseColor.setValue (0.3, 0.8, 0.0);
00798 sep->addChild (mat);
00799
00800 SoDrawStyle *drawStyle = new SoDrawStyle;
00801 drawStyle->pointSize = 3.0;
00802 sep->addChild (drawStyle);
00803
00804 try
00805 {
00806 SoVertexProperty *vertices = new SoVertexProperty;
00807 int nVrx = 0;
00808
00809 for (std::vector<std::pair<CSCDetId, CSCWireDigi> >::const_iterator i = m_digis.begin (), iEnd = m_digis.end (); i != iEnd; ++i)
00810 {
00811 Surface::GlobalPoint pos = (m_pDD->idToDet ((*i).first))->surface ().position ();
00812
00813
00814
00815 float x = pos.x () / 100.0;
00816 float y = pos.y () / 100.0;
00817 float z = pos.z () / 100.0;
00818
00819 vertices->vertex.set1Value (nVrx++, SbVec3f (x, y, z));
00820 }
00821 vertices->vertex.setNum (m_digis.size ());
00822
00823 SoPointSet *points = new SoPointSet;
00824 points->vertexProperty.setValue (vertices);
00825 points->numPoints.setValue (m_digis.size ());
00826 sep->addChild (points);
00827 }
00828 catch (cms::Exception& e)
00829 {
00830 if (this->m_onCmsException)
00831 this->m_onCmsException (&e);
00832 }
00833 catch (lat::Error &e)
00834 {
00835 if (this->m_onError)
00836 this->m_onError (&e);
00837 }
00838 catch (std::exception &e)
00839 {
00840 if (this->m_onException)
00841 this->m_onException (&e);
00842 }
00843 catch (...)
00844 {
00845 if (this->m_onUnhandledException)
00846 this->m_onUnhandledException ();
00847 }
00848 rep->node ()->addChild (sep);
00849 }
00850 }