CMS 3D CMS Logo

VisTrack Class Reference

#include <VisReco/Analyzer/interface/VisTrack.h>

Inheritance diagram for VisTrack:

edm::EDAnalyzer

List of all members.

Public Member Functions

virtual void analyze (const edm::Event &, const edm::EventSetup &)
 VisTrack (const edm::ParameterSet &)
virtual ~VisTrack ()

Private Attributes

edm::InputTag inputTag_


Detailed Description

Definition at line 18 of file VisTrack.h.


Constructor & Destructor Documentation

VisTrack::VisTrack ( const edm::ParameterSet iConfig  )  [explicit]

Definition at line 42 of file VisTrack.cc.

00043     : inputTag_ (iConfig.getParameter<edm::InputTag>("visTrackTag"))
00044 {}

virtual VisTrack::~VisTrack (  )  [inline, virtual]

Definition at line 26 of file VisTrack.h.

00026 {}


Member Function Documentation

void VisTrack::analyze ( const edm::Event event,
const edm::EventSetup eventSetup 
) [virtual]

Implements edm::EDAnalyzer.

Definition at line 47 of file VisTrack.cc.

References IgCollection::addProperty(), IgAssociationSet::associate(), collection, edmplugin::standard::config(), IgCollection::create(), error, ETA, Exception, edm::EventSetup::get(), IgDataStorage::getAssociationSet(), IgDataStorage::getCollection(), inputTag_, edm::InputTag::instance(), edm::Service< T >::isAvailable(), edm::Handle< T >::isValid(), edm::ESHandle< T >::isValid(), it, edm::InputTag::label(), VisLocalPosition::localPosition(), P, PHI, edm::InputTag::process(), edm::ESHandle< T >::product(), PT, track, and tracks.

00048 {
00049     edm::Service<IguanaService> config;
00050     if (! config.isAvailable ()) 
00051     {
00052         throw cms::Exception ("Configuration")
00053             << "VisTrack requires the IguanaService\n"
00054             "which is not present in the configuration file.\n"
00055             "You must add the service in the configuration file\n"
00056             "or remove the module that requires it";
00057     }
00058     
00059     edm::Handle<reco::TrackCollection> collection;
00060     event.getByLabel (inputTag_, collection);
00061 
00062     edm::ESHandle<GlobalTrackingGeometry> geometry;
00063     eventSetup.get<GlobalTrackingGeometryRecord> ().get (geometry);
00064 
00065     edm::ESHandle<MagneticField> field;    
00066     eventSetup.get<IdealMagneticFieldRecord> ().get (field);
00067 
00068     if (collection.isValid () && geometry.isValid () && field.isValid ())
00069     {       
00070         IgDataStorage *storage = config->storage ();
00071         IgCollection &tracks = storage->getCollection ("Tracks_V1");
00072 
00073         IgProperty VTX = tracks.addProperty ("pos", IgV3d());
00074         IgProperty P   = tracks.addProperty ("dir", IgV3d());
00075         IgProperty PT  = tracks.addProperty ("pt", static_cast<double>(0.0)); 
00076         IgProperty PHI = tracks.addProperty ("phi", static_cast<double>(0.0));
00077         IgProperty ETA = tracks.addProperty ("eta", static_cast<double>(0.0));
00078         IgProperty CHARGE = tracks.addProperty ("charge", static_cast<double>(0.0));
00079 
00080         // Create a collection for track extras.
00081         IgCollection &extras = storage->getCollection ("Extras_V1");
00082         IgProperty IPOS = extras.addProperty ("pos_1", IgV3d());
00083         IgProperty IP   = extras.addProperty ("dir_1", IgV3d());
00084         IgProperty OPOS = extras.addProperty ("pos_2", IgV3d());
00085         IgProperty OP   = extras.addProperty ("dir_2", IgV3d());
00086  
00087         IgAssociationSet &trackExtras = storage->getAssociationSet ("TrackExtras_V1");
00088 
00089         // Create a collection for tracking rec hits.
00090         IgCollection &hits = storage->getCollection ("Hits_V1");
00091         IgProperty HIT_POS = hits.addProperty ("pos", IgV3d());
00092 
00093         IgAssociationSet &trackHits = storage->getAssociationSet ("TrackHits_V1");
00094  
00095         for (reco::TrackCollection::const_iterator track = collection->begin (), trackEnd = collection->end ();
00096              track != trackEnd; ++track)
00097         {
00098             IgCollectionItem item = tracks.create ();
00099             item[VTX] = IgV3d(static_cast<double>((*track).referencePoint().x()/100.),
00100                               static_cast<double>((*track).referencePoint().y()/100.),
00101                               static_cast<double>((*track).referencePoint().z()/100.));
00102             item[P]   = IgV3d(static_cast<double>((*track).px()),
00103                               static_cast<double>((*track).py()),
00104                               static_cast<double>((*track).pz()));
00105             item[PT]  = static_cast<double>((*track).pt ());
00106             item[PHI] = static_cast<double>((*track).phi ());
00107             item[ETA] = static_cast<double>((*track).eta ());
00108             item[CHARGE] = static_cast<double>((*track).charge ());
00109             
00110             if ((*track).innerOk () && (*track).outerOk ())
00111             {
00112                 IgCollectionItem eitem = extras.create ();
00113                 eitem[IPOS]  = IgV3d(static_cast<double>((*track).innerPosition().x()/100.0),
00114                                      static_cast<double>((*track).innerPosition().y()/100.0),
00115                                      static_cast<double>((*track).innerPosition().z()/100.0));
00116                 eitem[IP]    = IgV3d(static_cast<double>((*track).innerMomentum().x()),
00117                                      static_cast<double>((*track).innerMomentum().y()),
00118                                      static_cast<double>((*track).innerMomentum().z()));
00119                 eitem[OPOS]  = IgV3d(static_cast<double>((*track).outerPosition().x()/100.0),
00120                                      static_cast<double>((*track).outerPosition().y()/100.0),
00121                                      static_cast<double>((*track).outerPosition().z()/100.0));
00122                 eitem[OP]     = IgV3d(static_cast<double>((*track).outerMomentum().x()),
00123                                       static_cast<double>((*track).outerMomentum ().y ()),
00124                                       static_cast<double>((*track).outerMomentum ().z ()));
00125 
00126                 trackExtras.associate (item, eitem);
00127             }
00128             
00129             if ((*track).extra ().isNonnull ())
00130             {
00131                 for (trackingRecHit_iterator it = track->recHitsBegin ();  it != track->recHitsEnd (); ++it) 
00132                 {
00133                     if ((*it)->isValid () && !(*it)->geographicalId ().null ())
00134                     {
00135                         IgCollectionItem hit = hits.create ();
00136                         LocalPoint point = VisLocalPosition::localPosition(&(**it), geometry.product());
00137                         hit[HIT_POS] = IgV3d(static_cast<double>(geometry->idToDet((*it)->geographicalId())->surface().toGlobal(point).x()/100.0),
00138                                              static_cast<double>(geometry->idToDet((*it)->geographicalId())->surface().toGlobal(point).y()/100.0),
00139                                              static_cast<double>(geometry->idToDet((*it)->geographicalId())->surface().toGlobal(point).z()/100.0));
00140 
00141                         trackHits.associate (item, hit);
00142                     }
00143                 }
00144             }
00145         }
00146     }
00147     else 
00148     {
00149         // friendlyName:moduleLabel:instanceName:processName
00150         std::string error = "### Error: Tracks "
00151                             + edm::TypeID (typeid (reco::TrackCollection)).friendlyClassName () + ":" 
00152                             + inputTag_.label() + ":"
00153                             + inputTag_.instance() + ":" 
00154                             + inputTag_.process() + " are not found.";
00155 
00156         IgDataStorage *storage = config->storage ();
00157         IgCollection &collection = storage->getCollection ("Errors_V1");
00158         IgProperty ERROR_MSG = collection.addProperty ("Error", std::string ());
00159         IgCollectionItem item = collection.create ();
00160         item [ERROR_MSG] = error;
00161     }
00162 }


Member Data Documentation

edm::InputTag VisTrack::inputTag_ [private]

Definition at line 31 of file VisTrack.h.

Referenced by analyze().


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