CMS 3D CMS Logo

VisG4TrackPtTwig Class Reference

#include <VisSimulation/VisSimBase/interface/VisG4TrackPtTwig.h>

Inheritance diagram for VisG4TrackPtTwig:

VisQueuedTwig IgSimpleTwig VisEventObserver IgCompoundTwig IgTwig IgRepresentable

List of all members.

Public Member Functions

virtual void cutChanged (void)
virtual void update (Ig3DRep *rep)
virtual void update (IgTextRep *rep)
 VisG4TrackPtTwig (IgState *state, IgTwig *parent, std::string name, unsigned colour, bool highpt, VisG4TracksTwig *tracks, const int *ids)

Private Member Functions

bool rejectTrajectory (const G4Trajectory *traj) const

Private Attributes

const intm_ids
bool m_inclusive
bool m_isHighPt
unsigned m_rgba
VisG4TracksTwigm_tracks


Detailed Description

Definition at line 20 of file VisG4TrackPtTwig.h.


Constructor & Destructor Documentation

VisG4TrackPtTwig::VisG4TrackPtTwig ( IgState state,
IgTwig parent,
std::string  name,
unsigned  colour,
bool  highpt,
VisG4TracksTwig tracks,
const int ids 
)

Definition at line 41 of file VisG4TrackPtTwig.cc.

00044     : VisQueuedTwig (state, parent, name),
00045       m_tracks (tracks),
00046       m_isHighPt (highpt),
00047       m_ids (ids),
00048       m_rgba (colour)
00049 {}


Member Function Documentation

void VisG4TrackPtTwig::cutChanged ( void   )  [virtual]

Definition at line 52 of file VisG4TrackPtTwig.cc.

References IgRepSet::invalidate(), and IgTwig::SELF_MASK.

00053 { IgRepSet::invalidate (this, SELF_MASK); }

bool VisG4TrackPtTwig::rejectTrajectory ( const G4Trajectory *  traj  )  const [private]

Definition at line 56 of file VisG4TrackPtTwig.cc.

References ASSERT, VisG4TracksTwig::CHARGE, VisG4TracksTwig::CHARGED, i, int, m_ids, m_isHighPt, VisG4TracksTwig::NEUTRAL, p, VisG4TracksTwig::PARTICLE, and funct::sqrt().

Referenced by update().

00057 {
00058     // Check if it passes pt cut
00059     Hep3Vector  p = traj->GetInitialMomentum ();
00060     double      px = p.x () / GeV;
00061     double      py = p.y () / GeV;
00062     double      pt = sqrt (px * px + py * py);
00063 
00064     if ((m_isHighPt)
00065         || (! m_isHighPt))
00066         return true;
00067 
00068     // Check if it passes eta cut?
00069     // if ( ... > m_etaCut.value ())
00070     //     return true;
00071 
00072     // Check if the particle should be accepted.  We accept three params
00073     // in the "m_ids" array.  Firstly, there can be a "CHARGE" setting,
00074     // accepting or passing by particle charge.  Then there can be a
00075     // section of "PARTICLE" type; the list can indicate an inclusive
00076     // list (only particles mentioned will be accepted) or exclusive
00077     // (particles other than those mentioned will be accepted).
00078     const int *ids = m_ids;
00079     
00080     // First check for general charge setting; if it fails, quit early
00081     if (ids [0] == VisG4TracksTwig::CHARGE)
00082     {
00083         int charge = (int) traj->GetCharge ();
00084 
00085         if (ids [1] == VisG4TracksTwig::CHARGED)
00086         {
00087             if (charge == 0)
00088                 return true;
00089         }
00090         else if (ids [1] == VisG4TracksTwig::NEUTRAL)
00091         {
00092             if (charge != 0)
00093                 return true;
00094         }
00095         else
00096             ASSERT (false);
00097         
00098         ids += 2;
00099     }
00100 
00101     // Now check for particle choice.  Negative PARTICLE means exclusion.
00102     ASSERT (ids [0] == VisG4TracksTwig::PARTICLE
00103             || ids [0] == -VisG4TracksTwig::PARTICLE);
00104 
00105     int         partId = traj->GetPDGEncoding ();
00106     bool        inclusive = (ids [0] == VisG4TracksTwig::PARTICLE);
00107     int         nparts = ids [1];
00108     bool        isOfType = false;
00109 
00110     for (int i = 0; !isOfType && i < nparts; ++i)
00111          isOfType = isOfType || (partId == ids [2 + i]);
00112 
00113     return inclusive != isOfType;
00114 }

void VisG4TrackPtTwig::update ( Ig3DRep rep  )  [virtual]

Reimplemented from VisQueuedTwig.

Definition at line 199 of file VisG4TrackPtTwig.cc.

References ASSERT, darken(), group, i, j, parsecf::pyparsing::line(), funct::log(), m, m_rgba, m_tracks, Ig3DBaseRep::node(), p, rejectTrajectory(), funct::sqrt(), cmsRelvalreportInput::step, VisG4TracksTwig::trajectories(), and VisQueuedTwig::update().

00200 {
00201     // Get debugging dump
00202     VisQueuedTwig::update (rep);
00203 
00204     // Prepare parent container
00205     qApp->lock ();
00206     SoGroup *contents = rep->node ();
00207     contents->removeAllChildren ();
00208 
00209     // Process all trajectories
00210     G4TrajectoryContainer *trajs = m_tracks->trajectories ();
00211     for (int i = 0; i < trajs->entries (); ++i)
00212     {
00213         // FIXME: separate ideal track from momentum and charge?
00214 
00215         ASSERT (dynamic_cast<G4Trajectory *> ((*trajs) [i]));
00216         G4Trajectory *traj = static_cast<G4Trajectory *> ((*trajs) [i]);
00217         if (rejectTrajectory (traj))
00218             continue;
00219 
00220         static SoDrawStyle *thick = 0;
00221         static SoDrawStyle *thin = 0;
00222         if (! thick)
00223         {
00224             thick = new SoDrawStyle;
00225             thick->lineWidth = 2.0;
00226             thick->ref ();
00227 
00228             thin = new SoDrawStyle;
00229             thin->lineWidth = 1.0;
00230             thin->ref ();
00231         }
00232 
00233         SoSeparator     *group = new SoSeparator;
00234         SoLineSet       *line = new SoLineSet;
00235         SoVertexProperty *vtx = new SoVertexProperty;
00236         int             npoints = traj->GetPointEntries ();
00237         SbVec3f         *points;
00238 
00239         // Colour the track by pT.  Ramp logarithmically from 2 GeV (50%)
00240         // to 20 GeV (100%) as a function of pT.
00241         Hep3Vector      p = traj->GetInitialMomentum ();
00242         double          px = p.x () / GeV;
00243         double          py = p.y () / GeV;
00244         double          pt = sqrt (px * px + py * py);
00245         double          ptscale = (pt <= 2 ? .5
00246                                    : pt <= 20 ? .5 + log(pt) / log(20.) * .5
00247                                    : 1);
00248         SoDrawStyle     *style = pt < 20 ? thin : thick;
00249         vtx->materialBinding = SoVertexProperty::OVERALL;
00250         vtx->orderedRGBA = darken (m_rgba, ptscale);
00251 
00252         // Get which step to draw
00253         int step = 1; // FIXME: m_step.value ();
00254         
00255         // Collect trajectory points
00256         int nVertices = 0;
00257         
00258         vtx->vertex.setNum (npoints);
00259         points = vtx->vertex.startEditing ();
00260         for (int j = 0; j < npoints; ++j)
00261         {
00262             G4VTrajectoryPoint *vp = traj->GetPoint (j);
00263             ASSERT (dynamic_cast<G4TrajectoryPoint *> (vp));
00264             G4ThreeVector pt = static_cast<G4TrajectoryPoint *> (vp)->GetPosition ();
00265             if (j % step == 0 || j == npoints - 1) 
00266             {
00267                 points [nVertices] = SbVec3f (pt.x () / m, pt.y () / m, pt.z () / m);
00268                 nVertices++;
00269             }
00270         }
00271         
00272         vtx->vertex.finishEditing ();
00273         line->numVertices = nVertices;
00274         line->vertexProperty = vtx;
00275         group->addChild (style);
00276         group->addChild (line);
00277         contents->addChild (group);
00278     }
00279 
00280     qApp->unlock (false);
00281 }

void VisG4TrackPtTwig::update ( IgTextRep rep  )  [virtual]

Reimplemented from VisQueuedTwig.

Definition at line 117 of file VisG4TrackPtTwig.cc.

References ASSERT, i, int, m_isHighPt, m_tracks, IgSimpleTwig::name(), p, rejectTrajectory(), IgTextRep::setText(), funct::sqrt(), VisG4TracksTwig::trajectories(), and VisQueuedTwig::update().

00118 {
00119     // Get debugging dump
00120     VisQueuedTwig::update (rep);
00121 
00122     // Prepare property description.
00123     G4TrajectoryContainer       *trajs = m_tracks->trajectories ();
00124     std::ostringstream          text;
00125     std::ostringstream          preamble;
00126     int                         nSelected = 0;
00127 
00128     text << std::setiosflags (std::ios::showpoint | std::ios::fixed);
00129     text.setf (std::ios::right, std::ios::adjustfield);
00130 
00131     for (int i = 0; i < trajs->entries (); ++i)
00132     {
00133         ASSERT (dynamic_cast<G4Trajectory *> ((*trajs) [i]));
00134         G4Trajectory *traj = static_cast<G4Trajectory *> ((*trajs) [i]);
00135         if (rejectTrajectory (traj))
00136             continue;
00137 
00138         if (++nSelected == 1)
00139         {
00140             text << "<table width='100%' border='1'>\n"
00141                  << "<tr align='center'>"
00142                  << "<th>ID</th>"
00143                  << "<th>Parent ID</th>"
00144                  << "<th>Name</th>"
00145                  << "<th>Charge</th>"
00146                  << "<th>p<sub>T</sub></th>"
00147                  << "<th>p<sub>x</sub></th>"
00148                  << "<th>p<sub>y</sub></th>"
00149                  << "<th>p<sub>z</sub></th>"
00150                  << "<th>Points</th>"
00151                  // << "<th>E [GeV]</th>"
00152                  // << "<th>p<sub>T</sub> [GeV/c]</th>"
00153                  // << "<th>charge</th>"
00154                  // << "<th>eta</th>"
00155                  // << "<th>phi [rad]</th>"
00156                  // << "<th>vertex position [cm]</th>"
00157                  << "</tr>";
00158         }
00159 
00160         Hep3Vector      p = traj->GetInitialMomentum ();
00161         double          px = p.x () / GeV;
00162         double          py = p.y () / GeV;
00163         double          pz = p.z () / GeV;
00164         double          pt = sqrt (px * px + py * py);
00165 
00166         text << "<tr align='right'>"
00167              << "<td>" << traj->GetTrackID () << "</td>"
00168              << "<td>" << traj->GetParentID () << "</td>"
00169              << "<td>" << traj->GetParticleName () << "</td>"
00170              << "<td>" << (int) traj->GetCharge () << "</td>"
00171              << "<td>" << std::setprecision (2) << pt << "</td>"
00172              << "<td>" << std::setprecision (2) << px << "</td>"
00173              << "<td>" << std::setprecision (2) << py << "</td>"
00174              << "<td>" << std::setprecision (2) << pz << "</td>"
00175              << "<td>" << traj->GetPointEntries () << "</td>"
00176              << "</tr>";
00177     }
00178 
00179     if (nSelected)
00180     {
00181         text << "</table>\n";
00182         preamble << "<p>" << name () << " with p<sub>T</sub> "
00183                  << (m_isHighPt ? "over " : "under ")
00184                  << std::setprecision (2) << "FIXME: NO CUT"
00185                  << ": " << nSelected << " trajectories</p>";
00186     }
00187     else
00188         text << "<p>No " << name () << " with p<sub>T</sub> "
00189              << (m_isHighPt ? "over " : "under ")
00190              << std::setprecision (2) << "FIXME: NO CUT" << "</p>";
00191 
00192     // Send it over.
00193     qApp->lock ();
00194     rep->setText (preamble.str () + text.str ());
00195     qApp->unlock (false);
00196 }


Member Data Documentation

const int* VisG4TrackPtTwig::m_ids [private]

Definition at line 38 of file VisG4TrackPtTwig.h.

Referenced by rejectTrajectory().

bool VisG4TrackPtTwig::m_inclusive [private]

Definition at line 37 of file VisG4TrackPtTwig.h.

bool VisG4TrackPtTwig::m_isHighPt [private]

Definition at line 36 of file VisG4TrackPtTwig.h.

Referenced by rejectTrajectory(), and update().

unsigned VisG4TrackPtTwig::m_rgba [private]

Definition at line 39 of file VisG4TrackPtTwig.h.

Referenced by update().

VisG4TracksTwig* VisG4TrackPtTwig::m_tracks [private]

Definition at line 35 of file VisG4TrackPtTwig.h.

Referenced by update().


The documentation for this class was generated from the following files:
Generated on Tue Jun 9 18:35:24 2009 for CMSSW by  doxygen 1.5.4