CMS 3D CMS Logo

VisTrackingRecHit.cc

Go to the documentation of this file.
00001 //<<<<<< INCLUDES                                                       >>>>>>
00002 
00003 #include "VisReco/Analyzer/interface/VisTrackingRecHit.h"
00004 #include "VisReco/Analyzer/interface/VisLocalPosition.h"
00005 #include "VisReco/Analyzer/interface/IguanaService.h"
00006 #include "DataFormats/TrackingRecHit/interface/TrackingRecHitFwd.h"
00007 #include "DataFormats/TrackingRecHit/interface/TrackingRecHit.h"
00008 #include "FWCore/Framework/interface/Event.h"
00009 #include "FWCore/Framework/interface/EventSetup.h"
00010 #include "FWCore/Framework/interface/ESHandle.h"
00011 #include "FWCore/Framework/interface/MakerMacros.h"
00012 #include "FWCore/ParameterSet/interface/ParameterSet.h"
00013 #include "FWCore/ServiceRegistry/interface/Service.h"
00014 #include "Geometry/CommonDetUnit/interface/GeomDet.h"
00015 #include "Geometry/CommonDetUnit/interface/GeomDetUnit.h"
00016 #include "Geometry/CommonDetUnit/interface/GlobalTrackingGeometry.h"
00017 #include "Geometry/Records/interface/GlobalTrackingGeometryRecord.h"
00018 #include "Iguana/Framework/interface/IgCollection.h"
00019 
00020 //<<<<<< PRIVATE DEFINES                                                >>>>>>
00021 //<<<<<< PRIVATE CONSTANTS                                              >>>>>>
00022 //<<<<<< PRIVATE TYPES                                                  >>>>>>
00023 //<<<<<< PRIVATE VARIABLE DEFINITIONS                                   >>>>>>
00024 //<<<<<< PUBLIC VARIABLE DEFINITIONS                                    >>>>>>
00025 //<<<<<< CLASS STRUCTURE INITIALIZATION                                 >>>>>>
00026 //<<<<<< PRIVATE FUNCTION DEFINITIONS                                   >>>>>>
00027 //<<<<<< PUBLIC FUNCTION DEFINITIONS                                    >>>>>>
00028 //<<<<<< MEMBER FUNCTION DEFINITIONS                                    >>>>>>
00029 
00030 using namespace edm::service;
00031 
00032 VisTrackingRecHit::VisTrackingRecHit (const edm::ParameterSet& iConfig)
00033     : inputTag_ (iConfig.getParameter<edm::InputTag>("visTrackingRecHitTag"))
00034 {}
00035 
00036 void
00037 VisTrackingRecHit::analyze( const edm::Event& event, const edm::EventSetup& eventSetup)
00038 {
00039     edm::Service<IguanaService> config;
00040     if (! config.isAvailable ()) 
00041     {
00042         throw cms::Exception ("Configuration")
00043             << "VisTrackingRecHit requires the IguanaService\n"
00044             "which is not present in the configuration file.\n"
00045             "You must add the service in the configuration file\n"
00046             "or remove the module that requires it";
00047     }
00048     
00049     edm::Handle<TrackingRecHitCollection> collection;
00050     event.getByLabel (inputTag_, collection);
00051  
00052     edm::ESHandle<GlobalTrackingGeometry> geom;
00053     eventSetup.get<GlobalTrackingGeometryRecord> ().get (geom);
00054 
00055     if (collection.isValid () && geom.isValid ())
00056     {       
00057         IgDataStorage *storage = config->storage ();
00058         IgCollection &recHits = storage->getCollection("TrackingRecHits_V1");
00059         IgProperty POS = recHits.addProperty("pos", IgV3d());
00060 
00061         for (TrackingRecHitCollection::const_iterator it=collection->begin(), itEnd=collection->end(); it!=itEnd; ++it)
00062         {
00063             if ((*it).isValid () && !(*it).geographicalId ().null ())
00064             {
00065                 LocalPoint point = VisLocalPosition::localPosition(&(*it), geom.product ());
00066                 float x = geom->idToDet ((*it).geographicalId ())->surface ().toGlobal (point).x () / 100.0;
00067                 float y = geom->idToDet ((*it).geographicalId ())->surface ().toGlobal (point).y () / 100.0;
00068                 float z = geom->idToDet ((*it).geographicalId ())->surface ().toGlobal (point).z () / 100.0;
00069 
00070                 IgCollectionItem irechit = recHits.create();
00071                 irechit[POS] = IgV3d (static_cast<double>(x), static_cast<double>(y), static_cast<double>(z));
00072             }       
00073         }
00074     }
00075     else 
00076     {
00077         // friendlyName:moduleLabel:instanceName:processName
00078         std::string error = "### Error: TrackingRecHits "
00079                             + edm::TypeID (typeid (TrackingRecHitCollection)).friendlyClassName () + ":" 
00080                             + inputTag_.label() + ":"
00081                             + inputTag_.instance() + ":" 
00082                             + inputTag_.process() + " are not found.";
00083 
00084         IgDataStorage *storage = config->storage ();
00085         IgCollection &collection = storage->getCollection ("Errors_V1");
00086         IgProperty ERROR_MSG = collection.addProperty ("Error", std::string ());
00087         IgCollectionItem item = collection.create ();
00088         item [ERROR_MSG] = error;
00089     }
00090 }
00091 
00092 DEFINE_FWK_MODULE(VisTrackingRecHit);

Generated on Tue Jun 9 17:50:10 2009 for CMSSW by  doxygen 1.5.4