00001
00002
00003 #include "VisSimulation/VisSimHits/interface/VisSimTrackTwig.h"
00004 #include "VisFramework/VisFrameworkBase/interface/VisTwigFactroyService.h"
00005 #include "VisFramework/VisFrameworkBase/interface/VisEventSelector.h"
00006 #include "VisFramework/VisFrameworkBase/interface/debug.h"
00007 #include "FWCore/Framework/interface/Event.h"
00008 #include "FWCore/Framework/interface/EventSetup.h"
00009 #include "SimDataFormats/Track/interface/SimTrack.h"
00010 #include "SimDataFormats/Track/interface/SimTrackContainer.h"
00011 #include "SimDataFormats/Vertex/interface/SimVertex.h"
00012 #include "SimDataFormats/Vertex/interface/SimVertexContainer.h"
00013 #include "Iguana/Inventor/interface/IgSoIdealTrack.h"
00014 #include "Iguana/Inventor/interface/IgSoSimpleTrajectory.h"
00015 #include "Iguana/Inventor/interface/IgParticleChar.h"
00016 #include "Iguana/Studio/interface/IgQtLock.h"
00017 #include "Iguana/Framework/interface/IgRepSet.h"
00018 #include "Iguana/GLModels/interface/Ig3DRep.h"
00019 #include "Iguana/GLModels/interface/IgLegoRep.h"
00020 #include "Iguana/GLModels/interface/IgRPhiRep.h"
00021 #include "Iguana/GLModels/interface/IgRZRep.h"
00022 #include "Iguana/Models/interface/IgTextRep.h"
00023 #include <Inventor/nodes/SoSeparator.h>
00024 #include <Inventor/nodes/SoDrawStyle.h>
00025 #include <Inventor/nodes/SoMaterial.h>
00026 #include <Inventor/nodes/SoText2.h>
00027 #include <Inventor/nodes/SoTranslation.h>
00028 #include <Inventor/actions/SoWriteAction.h>
00029 #include <Inventor/SoOutput.h>
00030 #include <qstring.h>
00031 #include <iostream>
00032 #include <iomanip>
00033
00034
00035
00036
00037
00038
00039
00040
00041
00042 namespace
00043 {
00044 VisQueuedTwig *
00045 createThisTwig (IgState *state, IgTwig *parent,
00046 const std::string &name,
00047 const std::string &friendlyName,
00048 const std::string &modLabel,
00049 const std::string &instanceName,
00050 const std::string &processName)
00051 {
00052 return new VisSimTrackTwig (state, parent, name, friendlyName, modLabel, instanceName, processName);
00053 }
00054 }
00055
00056
00057
00058
00059 VisSimTrackTwig::VisSimTrackTwig (IgState *state, IgTwig *parent, const std::string &name ,
00060 const std::string &friendlyName ,
00061 const std::string &moduleLabel ,
00062 const std::string &instanceName ,
00063 const std::string &processName )
00064 : VisQueuedTwig (state, parent, name),
00065 m_text (name),
00066 m_friendlyName (friendlyName),
00067 m_moduleLabel (moduleLabel),
00068 m_instanceName (instanceName),
00069 m_processName (processName),
00070 m_cut (state, lat::CreateCallback (this, &VisSimTrackTwig::cutChanged)),
00071 m_annot (state, lat::CreateCallback (this, &VisSimTrackTwig::cutChanged)),
00072 m_time (state, lat::CreateCallback (this, &VisSimTrackTwig::cutChanged))
00073 {
00074 VisTwigFactroyService *tfService = VisTwigFactroyService::get (state);
00075 if (! tfService)
00076 {
00077 tfService = new VisTwigFactroyService (state);
00078 }
00079 edm::TypeID simTracksID (typeid (edm::SimTrackContainer));
00080 tfService->registerTwig (simTracksID.friendlyClassName (), &createThisTwig);
00081 }
00082
00083 void
00084 VisSimTrackTwig::cutChanged (void)
00085 { IgRepSet::invalidate (this, SELF_MASK); }
00086
00087 void
00088 VisSimTrackTwig::onNewEvent (const edm::Event &event,
00089 const edm::EventSetup &eventSetup)
00090 {
00091
00092 VisQueuedTwig::onNewEvent (event, eventSetup);
00093
00094 m_tracks.clear ();
00095 m_vertices.clear ();
00096
00097 m_text = (QString ("Run # %1, event # %2")
00098 .arg (event.id ().run ())
00099 .arg (event.id ().event ()).latin1 ());
00100
00101 std::vector<edm::Handle<edm::SimTrackContainer> > trackCollections;
00102 std::vector<edm::Handle<edm::SimVertexContainer> > vertexCollections;
00103
00104 try
00105 {
00106 if ((! m_friendlyName.empty ()) || (! m_moduleLabel.empty ()) || (! m_instanceName.empty ()) || (! m_processName.empty ()))
00107 {
00108 VisEventSelector visSel (m_friendlyName, m_moduleLabel, m_instanceName, m_processName);
00109 event.getMany (visSel, trackCollections);
00110 }
00111 else
00112 {
00113 event.getManyByType (trackCollections);
00114 }
00115 event.getManyByType (vertexCollections);
00116 }
00117 catch (cms::Exception& e)
00118 {
00119 if (this->m_onCmsException)
00120 this->m_onCmsException (&e);
00121 }
00122 catch (lat::Error &e)
00123 {
00124 if (this->m_onError)
00125 this->m_onError (&e);
00126 }
00127 catch (std::exception &e)
00128 {
00129 if (this->m_onException)
00130 this->m_onException (&e);
00131 }
00132 catch (...)
00133 {
00134 if (this->m_onUnhandledException)
00135 this->m_onUnhandledException ();
00136 }
00137
00138 if (! trackCollections.empty ())
00139 {
00140 for (std::vector<edm::Handle<edm::SimTrackContainer> >::iterator i = trackCollections.begin (), iEnd = trackCollections.end ();
00141 i != iEnd; ++i)
00142 {
00143 const edm::SimTrackContainer& c = *(*i);
00144
00145 for (std::vector<SimTrack>::const_iterator isimt = c.begin (), isimtEnd = c.end ();
00146 isimt != isimtEnd; ++isimt)
00147 {
00148 m_tracks.push_back ((*isimt));
00149 }
00150 }
00151 }
00152
00153 if (! vertexCollections.empty ())
00154 {
00155 for (std::vector<edm::Handle<edm::SimVertexContainer> >::iterator i = vertexCollections.begin (), iEnd = vertexCollections.end ();
00156 i != iEnd; ++i)
00157 {
00158 const edm::SimVertexContainer& c = *(*i);
00159
00160 for (std::vector<SimVertex>::const_iterator isimv = c.begin (), isimvEnd = c.end ();
00161 isimv != isimvEnd; ++isimv)
00162 {
00163 m_vertices.push_back ((*isimv));
00164 }
00165 }
00166 }
00167
00168 VisQueuedTwig::onBaseInvalidate ();
00169 }
00170
00171 void
00172 VisSimTrackTwig::update (IgTextRep *rep)
00173 {
00174
00175 VisQueuedTwig::update (rep);
00176
00177
00178 std::ostringstream text;
00179 text << "Total " << m_tracks.size () << " sim tracks.<br>";
00180 text << "Above " << m_cut.value () << " GeV: <br>";
00181
00182 text << "<table width='100%' border=1>"
00183 << "<TR align = center>"
00184 << "<TH>Number</TH>"
00185 << "<TH>Track ID</TH>"
00186 << "<TH>Momentum</TH>"
00187 << "<TH>Hep PDT code</TH>"
00188 << "<TH>Vertex ID</TH>"
00189 << "</TR>";
00190 text << setiosflags (std::ios::showpoint | std::ios::fixed);
00191 text.setf (std::ios::right, std::ios::adjustfield);
00192
00193 if ((! m_tracks.empty ()))
00194 {
00195 int nTracks = 0;
00196 try
00197 {
00198 for (std::vector<SimTrack>::const_iterator i = m_tracks.begin (), iEnd = m_tracks.end (); i != iEnd; ++i)
00199 {
00200 float pt = (*i).momentum ().Pt();
00201 if (pt > m_cut.value ())
00202 {
00203 text << "<TR align = right>"
00204 << "<TD>" << std::setw (3) << nTracks++ << "</TD>"
00205 << "<TD>" << std::setw (3) << double ((*i).trackId ()) << "</TD>"
00206 << "<TD>" << std::setw (3) << pt << "</TD>"
00207 << "<TD>" << std::setw (3) << (*i).type () << "</TD>"
00208 << "<TD>" << std::setw (3) << (*i).vertIndex () << "</TD></TR>";
00209 }
00210 }
00211 }
00212 catch (cms::Exception& e)
00213 {
00214 if (this->m_onCmsException)
00215 this->m_onCmsException (&e);
00216 }
00217 catch (lat::Error &e)
00218 {
00219 if (this->m_onError)
00220 this->m_onError (&e);
00221 }
00222 catch (std::exception &e)
00223 {
00224 if (this->m_onException)
00225 this->m_onException (&e);
00226 }
00227 catch (...)
00228 {
00229 if (this->m_onUnhandledException)
00230 this->m_onUnhandledException ();
00231 }
00232 }
00233 text << "</table>";
00234
00235
00236 IgQtLock ();
00237 rep->setText (text.str ());
00238 }
00239
00240 void
00241 VisSimTrackTwig::update (Ig3DRep *rep)
00242 {
00243
00244 VisQueuedTwig::update (rep);
00245 IgQtLock ();
00246 rep->clear ();
00247
00248 if ((! m_tracks.empty ()))
00249 {
00250 SoSeparator *sep = new SoSeparator;
00251
00252 try
00253 {
00254 for (std::vector<SimTrack>::const_iterator i = m_tracks.begin (), iEnd = m_tracks.end (); i != iEnd; ++i)
00255 {
00256 float pt = (*i).momentum ().Pt();
00257 if (pt > m_cut.value ())
00258 {
00259 double x0 = 0.0;
00260 double y0 = 0.0;
00261 double z0 = 0.0;
00262
00263 if (! (*i).noVertex ())
00264 {
00265 int vInd = (*i).vertIndex ();
00266 x0 = (m_vertices.at (vInd)).position ().x () / 100.0;
00267 y0 = (m_vertices.at (vInd)).position ().y () / 100.0;
00268 z0 = (m_vertices.at (vInd)).position ().z () / 100.0;
00269 }
00270
00271 IgSoIdealTrack *kit = new IgSoIdealTrack;
00272
00273 SoSeparator *labelSep = new SoSeparator;
00274 QString label;
00275 SoText2 *trackLabel = new SoText2;
00276 SoTranslation *trackLabelTranslation = new SoTranslation;
00277
00278 SbVec3f pos = SbVec3f ((*i).trackerSurfacePosition ().x () / 100.0,
00279 (*i).trackerSurfacePosition ().y () / 100.0,
00280 (*i).trackerSurfacePosition ().z () / 100.0);
00281 trackLabelTranslation->translation = pos;
00282
00283 labelSep->addChild (trackLabelTranslation);
00284 labelSep->addChild (trackLabel);
00285
00286 switch ((*i).type ())
00287 {
00288 case 13:
00289 kit->initialise (x0, y0, z0,
00290 (*i).momentum ().x (), (*i).momentum ().y (), (*i).momentum ().z (),
00291 m_time.value (), IgParticleChar::getByName ("muon"));
00292 kit->radius = 25.0;
00293 label = QString ("mu %1 GeV").arg (pt, 0, 'g', 2);
00294 trackLabel->string = label.latin1 ();
00295
00296 sep->addChild (kit);
00297 break;
00298 case -13:
00299 kit->initialise (x0, y0, z0,
00300 (*i).momentum ().x (), (*i).momentum ().y (), (*i).momentum ().z (),
00301 m_time.value (), IgParticleChar::getByName ("antimuon"));
00302 kit->radius = 25.0;
00303
00304 label = QString ("mu- %1 GeV").arg (pt, 0, 'g', 2);
00305 trackLabel->string = label.latin1 ();
00306
00307 sep->addChild (kit);
00308 break;
00309 case 11:
00310 kit->initialise (x0, y0, z0,
00311 (*i).momentum ().x (), (*i).momentum ().y (), (*i).momentum ().z (),
00312 m_time.value (), IgParticleChar::getByName ("electron"));
00313
00314 label = QString ("e- %1 GeV").arg (pt, 0, 'g', 2);
00315 trackLabel->string = label.latin1 ();
00316
00317 sep->addChild (kit);
00318 break;
00319 case -11:
00320 kit->initialise (x0, y0, z0,
00321 (*i).momentum ().x (), (*i).momentum ().y (), (*i).momentum ().z (),
00322 m_time.value (), IgParticleChar::getByName ("positron"));
00323
00324 label = QString ("e+ %1 GeV").arg (pt, 0, 'g', 2);
00325 trackLabel->string = label.latin1 ();
00326
00327 sep->addChild (kit);
00328 break;
00329 case 211:
00330 kit->initialise (x0, y0, z0,
00331 (*i).momentum ().x (), (*i).momentum ().y (), (*i).momentum ().z (),
00332 m_time.value (), IgParticleChar::getByName ("antipion"));
00333
00334 label = QString ("pi+ %1 GeV").arg (pt, 0, 'g', 2);
00335 trackLabel->string = label.latin1 ();
00336
00337 sep->addChild (kit);
00338 break;
00339 case -211:
00340 kit->initialise (x0, y0, z0,
00341 (*i).momentum ().x (), (*i).momentum ().y (), (*i).momentum ().z (),
00342 m_time.value (), IgParticleChar::getByName ("pion"));
00343
00344 label = QString ("pi- %1 GeV").arg (pt, 0, 'g', 2);
00345 trackLabel->string = label.latin1 ();
00346
00347 sep->addChild (kit);
00348 break;
00349 case 2212:
00350 kit->initialise (x0, y0, z0,
00351 (*i).momentum ().x (), (*i).momentum ().y (), (*i).momentum ().z (),
00352 m_time.value (), IgParticleChar::getByName ("proton"));
00353
00354 label = QString ("p %1 GeV").arg (pt, 0, 'g', 2);
00355 trackLabel->string = label.latin1 ();
00356
00357 sep->addChild (kit);
00358 break;
00359 case -2212:
00360 kit->initialise (x0, y0, z0,
00361 (*i).momentum ().x (), (*i).momentum ().y (), (*i).momentum ().z (),
00362 m_time.value (), IgParticleChar::getByName ("antiproton"));
00363
00364 label = QString ("pbar %1 GeV").arg (pt, 0, 'g', 2);
00365 trackLabel->string = label.latin1 ();
00366
00367 sep->addChild (kit);
00368 break;
00369 case 130:
00370 kit->initialise (x0, y0, z0,
00371 (*i).momentum ().x (), (*i).momentum ().y (), (*i).momentum ().z (),
00372 m_time.value (), IgParticleChar::getByName ("kplus"));
00373
00374 label = QString ("Kl %1 GeV").arg (pt, 0, 'g', 2);
00375 break;
00376 case 310:
00377 kit->initialise (x0, y0, z0,
00378 (*i).momentum ().x (), (*i).momentum ().y (), (*i).momentum ().z (),
00379 m_time.value (), IgParticleChar::getByName ("kplus"));
00380
00381 label = QString ("Ks %1 GeV").arg (pt, 0, 'g', 2);
00382 break;
00383 case 321:
00384 kit->initialise (x0, y0, z0,
00385 (*i).momentum ().x (), (*i).momentum ().y (), (*i).momentum ().z (),
00386 m_time.value (), IgParticleChar::getByName ("kplus"));
00387
00388 label = QString ("K+ %1 GeV").arg (pt, 0, 'g', 2);
00389 trackLabel->string = label.latin1 ();
00390
00391 sep->addChild (kit);
00392 break;
00393 case -321:
00394 kit->initialise (x0, y0, z0,
00395 (*i).momentum ().x (), (*i).momentum ().y (), (*i).momentum ().z (),
00396 m_time.value (), IgParticleChar::getByName ("kminus"));
00397
00398 label = QString ("K- %1 GeV").arg (pt, 0, 'g', 2);
00399 trackLabel->string = label.latin1 ();
00400
00401 sep->addChild (kit);
00402 break;
00403 case 3312:
00404 kit->initialise (x0, y0, z0,
00405 (*i).momentum ().x (), (*i).momentum ().y (), (*i).momentum ().z (),
00406 m_time.value (), IgParticleChar::getByName ("ximinus"));
00407
00408 label = QString ("Xi- %1 GeV").arg (pt, 0, 'g', 2);
00409 trackLabel->string = label.latin1 ();
00410
00411 sep->addChild (kit);
00412 break;
00413 case -3122:
00414 break;
00415 case 2112:
00416 case -2112:
00417 case 22:
00418 {
00419 SoSeparator *gammas = new SoSeparator;
00420 SoMaterial *gammaMaterial = new SoMaterial;
00421 gammaMaterial->ambientColor.setValue (0.000, 0.000, 0.000);
00422 gammaMaterial->diffuseColor.setValue (1.000, 1.000, 0.000);
00423 gammaMaterial->emissiveColor.setValue (1.000, 1.000, 0.000);
00424 gammaMaterial->specularColor.setValue (0.000, 0.000, 0.000);
00425 gammaMaterial->shininess = 0.0;
00426 gammaMaterial->transparency = 0.0;
00427 gammas->addChild (gammaMaterial);
00428
00429 IgSoSimpleTrajectory *track = new IgSoSimpleTrajectory;
00430
00431 track->controlPoints.set1Value (0, SbVec3f (x0, y0, z0));
00432 track->markerPoints.set1Value (0, SbVec3f (x0, y0, z0));
00433
00434 track->controlPoints.set1Value (1, pos);
00435 track->markerPoints.set1Value (1, pos);
00436 gammas->addChild (track);
00437
00438 sep->addChild (gammas);
00439
00440 break;
00441 }
00442 default:
00443 break;
00444 }
00445 if (m_annot.value () == true)
00446 {
00447 sep->addChild (labelSep);
00448 }
00449 }
00450 }
00451 }
00452 catch (cms::Exception& e)
00453 {
00454 if (this->m_onCmsException)
00455 this->m_onCmsException (&e);
00456 }
00457 catch (lat::Error &e)
00458 {
00459 if (this->m_onError)
00460 this->m_onError (&e);
00461 }
00462 catch (std::exception &e)
00463 {
00464 if (this->m_onException)
00465 this->m_onException (&e);
00466 }
00467 catch (...)
00468 {
00469 if (this->m_onUnhandledException)
00470 this->m_onUnhandledException ();
00471 }
00472
00473 rep->node ()->addChild (sep);
00474 }
00475 }
00476
00477 void
00478 VisSimTrackTwig::update (IgLegoRep *rep)
00479 {
00480
00481 VisQueuedTwig::update (rep);
00482 }
00483
00484 void
00485 VisSimTrackTwig::update (IgRPhiRep *rep)
00486 {
00487
00488 VisQueuedTwig::update (rep);
00489 IgQtLock ();
00490 rep->clear ();
00491
00492 if ((! m_tracks.empty ()))
00493 {
00494 SoSeparator *sep = new SoSeparator;
00495
00496 try
00497 {
00498 for (std::vector<SimTrack>::const_iterator i = m_tracks.begin (), iEnd = m_tracks.end (); i != iEnd; ++i)
00499 {
00500 float pt = (*i).momentum ().Pt();
00501 if (pt > m_cut.value ())
00502 {
00503 double x0 = 0.0;
00504 double y0 = 0.0;
00505 double z0 = 0.0;
00506
00507 if (! (*i).noVertex ())
00508 {
00509 int vInd = (*i).vertIndex ();
00510 x0 = (m_vertices.at (vInd)).position ().x () / 100.0;
00511 y0 = (m_vertices.at (vInd)).position ().y () / 100.0;
00512 z0 = (m_vertices.at (vInd)).position ().z () / 100.0;
00513 }
00514
00515 IgSoIdealTrack *kit = new IgSoIdealTrack;
00516
00517
00518 SoSeparator *labelSep = new SoSeparator;
00519 QString label;
00520 SoText2 *trackLabel = new SoText2;
00521 SoTranslation *trackLabelTranslation = new SoTranslation;
00522
00523 SbVec3f pos = SbVec3f ((*i).trackerSurfacePosition ().x () / 100.0,
00524 (*i).trackerSurfacePosition ().y () / 100.0,
00525 (*i).trackerSurfacePosition ().z () / 100.0);
00526 trackLabelTranslation->translation = pos;
00527
00528 labelSep->addChild (trackLabelTranslation);
00529 labelSep->addChild (trackLabel);
00530
00531
00532 switch ((*i).type ())
00533 {
00534 case 13:
00535 kit->initialise (x0, y0, z0,
00536 (*i).momentum ().x (), (*i).momentum ().y (), (*i).momentum ().z (),
00537 m_time.value (), IgParticleChar::getByName ("muon"));
00538 kit->radius = 25.0;
00539 label = QString ("mu %1 GeV").arg (pt, 0, 'g', 2);
00540 trackLabel->string = label.latin1 ();
00541
00542 sep->addChild (kit);
00543 break;
00544 case -13:
00545 kit->initialise (x0, y0, z0,
00546 (*i).momentum ().x (), (*i).momentum ().y (), (*i).momentum ().z (),
00547 m_time.value (), IgParticleChar::getByName ("antimuon"));
00548 kit->radius = 25.0;
00549
00550 label = QString ("mu- %1 GeV").arg (pt, 0, 'g', 2);
00551 trackLabel->string = label.latin1 ();
00552
00553 sep->addChild (kit);
00554 break;
00555 case 11:
00556 kit->initialise (x0, y0, z0,
00557 (*i).momentum ().x (), (*i).momentum ().y (), (*i).momentum ().z (),
00558 m_time.value (), IgParticleChar::getByName ("electron"));
00559
00560 label = QString ("e- %1 GeV").arg (pt, 0, 'g', 2);
00561 trackLabel->string = label.latin1 ();
00562
00563 sep->addChild (kit);
00564 break;
00565 case -11:
00566 kit->initialise (x0, y0, z0,
00567 (*i).momentum ().x (), (*i).momentum ().y (), (*i).momentum ().z (),
00568 m_time.value (), IgParticleChar::getByName ("positron"));
00569
00570 label = QString ("e+ %1 GeV").arg (pt, 0, 'g', 2);
00571 trackLabel->string = label.latin1 ();
00572
00573 sep->addChild (kit);
00574 break;
00575 case 211:
00576 kit->initialise (x0, y0, z0,
00577 (*i).momentum ().x (), (*i).momentum ().y (), (*i).momentum ().z (),
00578 m_time.value (), IgParticleChar::getByName ("antipion"));
00579
00580 label = QString ("pi+ %1 GeV").arg (pt, 0, 'g', 2);
00581 trackLabel->string = label.latin1 ();
00582
00583 sep->addChild (kit);
00584 break;
00585 case -211:
00586 kit->initialise (x0, y0, z0,
00587 (*i).momentum ().x (), (*i).momentum ().y (), (*i).momentum ().z (),
00588 m_time.value (), IgParticleChar::getByName ("pion"));
00589
00590 label = QString ("pi- %1 GeV").arg (pt, 0, 'g', 2);
00591 trackLabel->string = label.latin1 ();
00592
00593 sep->addChild (kit);
00594 break;
00595 case 2212:
00596 kit->initialise (x0, y0, z0,
00597 (*i).momentum ().x (), (*i).momentum ().y (), (*i).momentum ().z (),
00598 m_time.value (), IgParticleChar::getByName ("proton"));
00599
00600 label = QString ("p %1 GeV").arg (pt, 0, 'g', 2);
00601 trackLabel->string = label.latin1 ();
00602
00603 sep->addChild (kit);
00604 break;
00605 case -2212:
00606 kit->initialise (x0, y0, z0,
00607 (*i).momentum ().x (), (*i).momentum ().y (), (*i).momentum ().z (),
00608 m_time.value (), IgParticleChar::getByName ("antiproton"));
00609
00610 label = QString ("pbar %1 GeV").arg (pt, 0, 'g', 2);
00611 trackLabel->string = label.latin1 ();
00612
00613 sep->addChild (kit);
00614 break;
00615 case 130:
00616 kit->initialise (x0, y0, z0,
00617 (*i).momentum ().x (), (*i).momentum ().y (), (*i).momentum ().z (),
00618 m_time.value (), IgParticleChar::getByName ("kplus"));
00619
00620 label = QString ("Kl %1 GeV").arg (pt, 0, 'g', 2);
00621 break;
00622 case 310:
00623 kit->initialise (x0, y0, z0,
00624 (*i).momentum ().x (), (*i).momentum ().y (), (*i).momentum ().z (),
00625 m_time.value (), IgParticleChar::getByName ("kplus"));
00626
00627 label = QString ("Ks %1 GeV").arg (pt, 0, 'g', 2);
00628 break;
00629 case 321:
00630 kit->initialise (x0, y0, z0,
00631 (*i).momentum ().x (), (*i).momentum ().y (), (*i).momentum ().z (),
00632 m_time.value (), IgParticleChar::getByName ("kplus"));
00633
00634 label = QString ("K+ %1 GeV").arg (pt, 0, 'g', 2);
00635 trackLabel->string = label.latin1 ();
00636
00637 sep->addChild (kit);
00638 break;
00639 case -321:
00640 kit->initialise (x0, y0, z0,
00641 (*i).momentum ().x (), (*i).momentum ().y (), (*i).momentum ().z (),
00642 m_time.value (), IgParticleChar::getByName ("kminus"));
00643
00644 label = QString ("K- %1 GeV").arg (pt, 0, 'g', 2);
00645 trackLabel->string = label.latin1 ();
00646
00647 sep->addChild (kit);
00648 break;
00649 case 3312:
00650 kit->initialise (x0, y0, z0,
00651 (*i).momentum ().x (), (*i).momentum ().y (), (*i).momentum ().z (),
00652 m_time.value (), IgParticleChar::getByName ("ximinus"));
00653
00654 label = QString ("Xi- %1 GeV").arg (pt, 0, 'g', 2);
00655 trackLabel->string = label.latin1 ();
00656
00657 sep->addChild (kit);
00658 break;
00659 case -3122:
00660 break;
00661 case 2112:
00662 case -2112:
00663 case 22:
00664 {
00665 SoSeparator *gammas = new SoSeparator;
00666 SoMaterial *gammaMaterial = new SoMaterial;
00667 gammaMaterial->ambientColor.setValue (0.000, 0.000, 0.000);
00668 gammaMaterial->diffuseColor.setValue (1.000, 1.000, 0.000);
00669 gammaMaterial->emissiveColor.setValue (1.000, 1.000, 0.000);
00670 gammaMaterial->specularColor.setValue (0.000, 0.000, 0.000);
00671 gammaMaterial->shininess = 0.0;
00672 gammaMaterial->transparency = 0.0;
00673 gammas->addChild (gammaMaterial);
00674
00675 IgSoSimpleTrajectory *track = new IgSoSimpleTrajectory;
00676
00677 track->controlPoints.set1Value (0, SbVec3f (x0, y0, z0));
00678 track->markerPoints.set1Value (0, SbVec3f (x0, y0, z0));
00679
00680 track->controlPoints.set1Value (1, pos);
00681 track->markerPoints.set1Value (1, pos);
00682 gammas->addChild (track);
00683
00684 sep->addChild (gammas);
00685
00686 break;
00687 }
00688 default:
00689 break;
00690 }
00691 if (m_annot.value () == true)
00692 {
00693 sep->addChild (labelSep);
00694 }
00695 }
00696 }
00697 }
00698 catch (cms::Exception& e)
00699 {
00700 if (this->m_onCmsException)
00701 this->m_onCmsException (&e);
00702 }
00703 catch (lat::Error &e)
00704 {
00705 if (this->m_onError)
00706 this->m_onError (&e);
00707 }
00708 catch (std::exception &e)
00709 {
00710 if (this->m_onException)
00711 this->m_onException (&e);
00712 }
00713 catch (...)
00714 {
00715 if (this->m_onUnhandledException)
00716 this->m_onUnhandledException ();
00717 }
00718
00719 rep->node ()->addChild (sep);
00720 }
00721 }
00722
00723 void
00724 VisSimTrackTwig::update (IgRZRep *rep)
00725 {
00726
00727 VisQueuedTwig::update (rep);
00728 IgQtLock ();
00729 rep->clear ();
00730
00731 if ((! m_tracks.empty ()))
00732 {
00733 SoSeparator *sep = new SoSeparator;
00734
00735 try
00736 {
00737 for (std::vector<SimTrack>::const_iterator i = m_tracks.begin (), iEnd = m_tracks.end (); i != iEnd; ++i)
00738 {
00739 float pt = (*i).momentum ().Pt();
00740 if (pt > m_cut.value ())
00741 {
00742 double x0 = 0.0;
00743 double y0 = 0.0;
00744 double z0 = 0.0;
00745
00746 if (! (*i).noVertex ())
00747 {
00748 int vInd = (*i).vertIndex ();
00749 x0 = (m_vertices.at (vInd)).position ().x () / 100.0;
00750 y0 = (m_vertices.at (vInd)).position ().y () / 100.0;
00751 z0 = (m_vertices.at (vInd)).position ().z () / 100.0;
00752 }
00753
00754 IgSoIdealTrack *kit = new IgSoIdealTrack;
00755
00756 SoSeparator *labelSep = new SoSeparator;
00757 QString label;
00758 SoText2 *trackLabel = new SoText2;
00759 SoTranslation *trackLabelTranslation = new SoTranslation;
00760
00761 SbVec3f pos = SbVec3f ((*i).trackerSurfacePosition ().x () / 100.0,
00762 (*i).trackerSurfacePosition ().y () / 100.0,
00763 (*i).trackerSurfacePosition ().z () / 100.0);
00764 trackLabelTranslation->translation = pos;
00765
00766 labelSep->addChild (trackLabelTranslation);
00767 labelSep->addChild (trackLabel);
00768
00769 switch ((*i).type ())
00770 {
00771 case 13:
00772 kit->initialise (x0, y0, z0,
00773 (*i).momentum ().x (), (*i).momentum ().y (), (*i).momentum ().z (),
00774 m_time.value (), IgParticleChar::getByName ("muon"));
00775 kit->radius = 25.0;
00776 label = QString ("mu %1 GeV").arg (pt, 0, 'g', 2);
00777 trackLabel->string = label.latin1 ();
00778
00779 sep->addChild (kit);
00780 break;
00781 case -13:
00782 kit->initialise (x0, y0, z0,
00783 (*i).momentum ().x (), (*i).momentum ().y (), (*i).momentum ().z (),
00784 m_time.value (), IgParticleChar::getByName ("antimuon"));
00785 kit->radius = 25.0;
00786
00787 label = QString ("mu- %1 GeV").arg (pt, 0, 'g', 2);
00788 trackLabel->string = label.latin1 ();
00789
00790 sep->addChild (kit);
00791 break;
00792 case 11:
00793 kit->initialise (x0, y0, z0,
00794 (*i).momentum ().x (), (*i).momentum ().y (), (*i).momentum ().z (),
00795 m_time.value (), IgParticleChar::getByName ("electron"));
00796
00797 label = QString ("e- %1 GeV").arg (pt, 0, 'g', 2);
00798 trackLabel->string = label.latin1 ();
00799
00800 sep->addChild (kit);
00801 break;
00802 case -11:
00803 kit->initialise (x0, y0, z0,
00804 (*i).momentum ().x (), (*i).momentum ().y (), (*i).momentum ().z (),
00805 m_time.value (), IgParticleChar::getByName ("positron"));
00806
00807 label = QString ("e+ %1 GeV").arg (pt, 0, 'g', 2);
00808 trackLabel->string = label.latin1 ();
00809
00810 sep->addChild (kit);
00811 break;
00812 case 211:
00813 kit->initialise (x0, y0, z0,
00814 (*i).momentum ().x (), (*i).momentum ().y (), (*i).momentum ().z (),
00815 m_time.value (), IgParticleChar::getByName ("antipion"));
00816
00817 label = QString ("pi+ %1 GeV").arg (pt, 0, 'g', 2);
00818 trackLabel->string = label.latin1 ();
00819
00820 sep->addChild (kit);
00821 break;
00822 case -211:
00823 kit->initialise (x0, y0, z0,
00824 (*i).momentum ().x (), (*i).momentum ().y (), (*i).momentum ().z (),
00825 m_time.value (), IgParticleChar::getByName ("pion"));
00826
00827 label = QString ("pi- %1 GeV").arg (pt, 0, 'g', 2);
00828 trackLabel->string = label.latin1 ();
00829
00830 sep->addChild (kit);
00831 break;
00832 case 2212:
00833 kit->initialise (x0, y0, z0,
00834 (*i).momentum ().x (), (*i).momentum ().y (), (*i).momentum ().z (),
00835 m_time.value (), IgParticleChar::getByName ("proton"));
00836
00837 label = QString ("p %1 GeV").arg (pt, 0, 'g', 2);
00838 trackLabel->string = label.latin1 ();
00839
00840 sep->addChild (kit);
00841 break;
00842 case -2212:
00843 kit->initialise (x0, y0, z0,
00844 (*i).momentum ().x (), (*i).momentum ().y (), (*i).momentum ().z (),
00845 m_time.value (), IgParticleChar::getByName ("antiproton"));
00846
00847 label = QString ("pbar %1 GeV").arg (pt, 0, 'g', 2);
00848 trackLabel->string = label.latin1 ();
00849
00850 sep->addChild (kit);
00851 break;
00852 case 130:
00853 kit->initialise (x0, y0, z0,
00854 (*i).momentum ().x (), (*i).momentum ().y (), (*i).momentum ().z (),
00855 m_time.value (), IgParticleChar::getByName ("kplus"));
00856
00857 label = QString ("Kl %1 GeV").arg (pt, 0, 'g', 2);
00858 break;
00859 case 310:
00860 kit->initialise (x0, y0, z0,
00861 (*i).momentum ().x (), (*i).momentum ().y (), (*i).momentum ().z (),
00862 m_time.value (), IgParticleChar::getByName ("kplus"));
00863
00864 label = QString ("Ks %1 GeV").arg (pt, 0, 'g', 2);
00865 break;
00866 case 321:
00867 kit->initialise (x0, y0, z0,
00868 (*i).momentum ().x (), (*i).momentum ().y (), (*i).momentum ().z (),
00869 m_time.value (), IgParticleChar::getByName ("kplus"));
00870
00871 label = QString ("K+ %1 GeV").arg (pt, 0, 'g', 2);
00872 trackLabel->string = label.latin1 ();
00873
00874 sep->addChild (kit);
00875 break;
00876 case -321:
00877 kit->initialise (x0, y0, z0,
00878 (*i).momentum ().x (), (*i).momentum ().y (), (*i).momentum ().z (),
00879 m_time.value (), IgParticleChar::getByName ("kminus"));
00880
00881 label = QString ("K- %1 GeV").arg (pt, 0, 'g', 2);
00882 trackLabel->string = label.latin1 ();
00883
00884 sep->addChild (kit);
00885 break;
00886 case 3312:
00887 kit->initialise (x0, y0, z0,
00888 (*i).momentum ().x (), (*i).momentum ().y (), (*i).momentum ().z (),
00889 m_time.value (), IgParticleChar::getByName ("ximinus"));
00890
00891 label = QString ("Xi- %1 GeV").arg (pt, 0, 'g', 2);
00892 trackLabel->string = label.latin1 ();
00893
00894 sep->addChild (kit);
00895 break;
00896 case -3122:
00897 break;
00898 case 2112:
00899 case -2112:
00900 case 22:
00901 {
00902 SoSeparator *gammas = new SoSeparator;
00903 SoMaterial *gammaMaterial = new SoMaterial;
00904 gammaMaterial->ambientColor.setValue (0.000, 0.000, 0.000);
00905 gammaMaterial->diffuseColor.setValue (1.000, 1.000, 0.000);
00906 gammaMaterial->emissiveColor.setValue (1.000, 1.000, 0.000);
00907 gammaMaterial->specularColor.setValue (0.000, 0.000, 0.000);
00908 gammaMaterial->shininess = 0.0;
00909 gammaMaterial->transparency = 0.0;
00910 gammas->addChild (gammaMaterial);
00911
00912 IgSoSimpleTrajectory *track = new IgSoSimpleTrajectory;
00913
00914 track->controlPoints.set1Value (0, SbVec3f (x0, y0, z0));
00915 track->markerPoints.set1Value (0, SbVec3f (x0, y0, z0));
00916
00917 track->controlPoints.set1Value (1, pos);
00918 track->markerPoints.set1Value (1, pos);
00919 gammas->addChild (track);
00920
00921 sep->addChild (gammas);
00922
00923 break;
00924 }
00925 default:
00926 break;
00927 }
00928 if (m_annot.value () == true)
00929 {
00930 sep->addChild (labelSep);
00931 }
00932 }
00933 }
00934 }
00935 catch (cms::Exception& e)
00936 {
00937 if (this->m_onCmsException)
00938 this->m_onCmsException (&e);
00939 }
00940 catch (lat::Error &e)
00941 {
00942 if (this->m_onError)
00943 this->m_onError (&e);
00944 }
00945 catch (std::exception &e)
00946 {
00947 if (this->m_onException)
00948 this->m_onException (&e);
00949 }
00950 catch (...)
00951 {
00952 if (this->m_onUnhandledException)
00953 this->m_onUnhandledException ();
00954 }
00955
00956 rep->node ()->addChild (sep);
00957 }
00958 }
00959