CMS 3D CMS Logo

VisSiStripDigi.cc

Go to the documentation of this file.
00001 //<<<<<< INCLUDES                                                       >>>>>>
00002 
00003 #include "VisReco/Analyzer/interface/VisSiStripDigi.h"
00004 #include "VisReco/Analyzer/interface/IguanaService.h"
00005 #include "DataFormats/Common/interface/DetSetVector.h"
00006 #include "DataFormats/SiStripDigi/interface/SiStripDigi.h"
00007 #include "FWCore/Framework/interface/Event.h"
00008 #include "FWCore/Framework/interface/ESHandle.h"
00009 #include "FWCore/Framework/interface/EventSetup.h"
00010 #include "FWCore/Framework/interface/MakerMacros.h"
00011 #include "FWCore/ParameterSet/interface/ParameterSet.h"
00012 #include "FWCore/ServiceRegistry/interface/Service.h"
00013 #include "FWCore/Utilities/interface/Exception.h"
00014 #include "Geometry/CommonTopologies/interface/StripTopology.h"
00015 #include "Geometry/Records/interface/TrackerDigiGeometryRecord.h"
00016 #include "Geometry/TrackerGeometryBuilder/interface/StripGeomDetUnit.h"
00017 #include "Geometry/TrackerGeometryBuilder/interface/TrackerGeometry.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 VisSiStripDigi::VisSiStripDigi (const edm::ParameterSet& iConfig)
00033     : inputTag_ (iConfig.getParameter<edm::InputTag>("visSiStripDigiTag"))
00034 {}
00035 
00036 void 
00037 VisSiStripDigi::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             << "VisSiStripDigi 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<edm::DetSetVector<SiStripDigi> > collection;
00050     event.getByLabel (inputTag_, collection);
00051 
00052     edm::ESHandle<TrackerGeometry> geom;
00053     eventSetup.get<TrackerDigiGeometryRecord> ().get (geom);
00054 
00055     if (collection.isValid () && geom.isValid ())
00056     {       
00057         IgDataStorage *storage = config->storage ();
00058         IgCollection &digis = storage->getCollection ("SiStripDigis_V1");
00059         IgProperty DET_ID   = digis.addProperty ("detid", int (0)); 
00060         IgProperty POS      = digis.addProperty ("pos", IgV3d());
00061 
00062         edm::DetSetVector<SiStripDigi>::const_iterator it = collection->begin ();
00063         edm::DetSetVector<SiStripDigi>::const_iterator end = collection->end ();
00064 
00065         for (; it != end; ++it)
00066         {
00067             edm::DetSet<SiStripDigi> ds = *it;
00068 
00069             if (ds.data.size ())
00070             {
00071                 const uint32_t& detID = ds.id;
00072                 DetId detid (detID);
00073                 edm::DetSet<SiStripDigi>::const_iterator idigi = ds.data.begin ();
00074                 edm::DetSet<SiStripDigi>::const_iterator idigiEnd = ds.data.end ();
00075                 for(; idigi != idigiEnd; ++idigi)
00076                 { 
00077                     const StripGeomDetUnit* stripDet = dynamic_cast<const StripGeomDetUnit *>(geom->idToDet (detid));
00078                     const StripTopology* stripTopol = dynamic_cast<const StripTopology *>( &(stripDet->specificTopology ()));
00079 
00080                     GlobalPoint pos = (geom->idToDet (detid))->surface ().toGlobal (stripTopol->localPosition ((*idigi).strip ()));
00081                     IgCollectionItem item = digis.create ();
00082                     item[DET_ID] = static_cast<int> (detID);
00083                     item[POS] = IgV3d(static_cast<double>(pos.x()/100.0), static_cast<double>(pos.y()/100.0), static_cast<double>(pos.z()/100.0));
00084                 }
00085             }
00086         }
00087     }
00088     else 
00089     {
00090         // friendlyName:moduleLabel:instanceName:processName
00091         std::string error = "### Error: SiStrip Digis "
00092                             + edm::TypeID (typeid (edm::DetSetVector<SiStripDigi>)).friendlyClassName () + ":" 
00093                             + inputTag_.label() + ":"
00094                             + inputTag_.instance() + ":" 
00095                             + inputTag_.process() + " are not found.";
00096 
00097         IgDataStorage *storage = config->storage ();
00098         IgCollection &collection = storage->getCollection ("Errors_V1");
00099         IgProperty ERROR_MSG = collection.addProperty ("Error", std::string ());
00100         IgCollectionItem item = collection.create ();
00101         item [ERROR_MSG] = error;
00102     }
00103 }
00104 
00105 DEFINE_FWK_MODULE(VisSiStripDigi);

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