00001 //<<<<<< INCLUDES >>>>>> 00002 00003 #include "VisReco/Analyzer/interface/VisSiPixelCluster.h" 00004 #include "VisReco/Analyzer/interface/IguanaService.h" 00005 #include "DataFormats/Common/interface/DetSetVectorNew.h" 00006 #include "DataFormats/SiPixelCluster/interface/SiPixelCluster.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/CommonDetUnit/interface/GeomDet.h" 00015 #include "Geometry/TrackerGeometryBuilder/interface/PixelGeomDetUnit.h" 00016 #include "Geometry/TrackerGeometryBuilder/interface/TrackerGeometry.h" 00017 #include "Geometry/TrackerTopology/interface/RectangularPixelTopology.h" 00018 #include "Geometry/Records/interface/TrackerDigiGeometryRecord.h" 00019 #include "Iguana/Framework/interface/IgCollection.h" 00020 00021 //<<<<<< PRIVATE DEFINES >>>>>> 00022 //<<<<<< PRIVATE CONSTANTS >>>>>> 00023 //<<<<<< PRIVATE TYPES >>>>>> 00024 //<<<<<< PRIVATE VARIABLE DEFINITIONS >>>>>> 00025 //<<<<<< PUBLIC VARIABLE DEFINITIONS >>>>>> 00026 //<<<<<< CLASS STRUCTURE INITIALIZATION >>>>>> 00027 //<<<<<< PRIVATE FUNCTION DEFINITIONS >>>>>> 00028 //<<<<<< PUBLIC FUNCTION DEFINITIONS >>>>>> 00029 //<<<<<< MEMBER FUNCTION DEFINITIONS >>>>>> 00030 00031 using namespace edm::service; 00032 00033 VisSiPixelCluster::VisSiPixelCluster (const edm::ParameterSet& iConfig) 00034 : inputTag_ (iConfig.getParameter<edm::InputTag>("visSiPixelClusterTag")) 00035 {} 00036 00037 void 00038 VisSiPixelCluster::analyze (const edm::Event& event, const edm::EventSetup& eventSetup) 00039 { 00040 edm::Service<IguanaService> config; 00041 if (! config.isAvailable ()) 00042 { 00043 throw cms::Exception ("Configuration") 00044 << "VisSiPixelCluster requires the IguanaService\n" 00045 "which is not present in the configuration file.\n" 00046 "You must add the service in the configuration file\n" 00047 "or remove the module that requires it"; 00048 } 00049 00050 edm::Handle<edmNew::DetSetVector<SiPixelCluster> > collection; 00051 event.getByLabel (inputTag_, collection); 00052 00053 edm::ESHandle<TrackerGeometry> geom; 00054 eventSetup.get<TrackerDigiGeometryRecord> ().get (geom); 00055 00056 if (collection.isValid () && geom.isValid ()) 00057 { 00058 IgDataStorage *storage = config->storage (); 00059 IgCollection &clusters = storage->getCollection ("SiPixelClusters_V1"); 00060 IgProperty DET_ID = clusters.addProperty ("detid", int (0)); 00061 IgProperty POS = clusters.addProperty ("pos", IgV3d()); 00062 00063 edmNew::DetSetVector<SiPixelCluster>::const_iterator it = collection->begin (); 00064 edmNew::DetSetVector<SiPixelCluster>::const_iterator end = collection->end (); 00065 00066 for (; it != end; ++it) 00067 { 00068 edmNew::DetSet<SiPixelCluster> ds = *it; 00069 const uint32_t detID = it->detId (); 00070 DetId detid (detID); 00071 00072 const PixelGeomDetUnit* theDet = dynamic_cast<const PixelGeomDetUnit *>(geom->idToDet (detid)); 00073 const RectangularPixelTopology *theTopol = dynamic_cast<const RectangularPixelTopology *>( &(theDet->specificTopology ())); 00074 00075 edmNew::DetSet<SiPixelCluster>::const_iterator icluster = it->begin (); 00076 edmNew::DetSet<SiPixelCluster>::const_iterator iclusterEnd = it->end (); 00077 00078 for(; icluster != iclusterEnd; ++icluster) 00079 { 00080 int row = (*icluster).minPixelRow (); 00081 int column = (*icluster).minPixelCol (); 00082 00083 GlobalPoint pos = (geom->idToDet (detid))->surface().toGlobal (theTopol->localPosition (MeasurementPoint (row, column))); 00084 IgCollectionItem item = clusters.create (); 00085 item[DET_ID] = static_cast<int> (detID); 00086 item[POS] = IgV3d(static_cast<double>(pos.x()/100.0), static_cast<double>(pos.y()/100.0), static_cast<double>(pos.z()/100.0)); 00087 } 00088 } 00089 } 00090 else 00091 { 00092 // friendlyName:moduleLabel:instanceName:processName 00093 std::string error = "### Error: SiPixel Clusters " 00094 + edm::TypeID (typeid (edmNew::DetSetVector<SiPixelCluster>)).friendlyClassName () + ":" 00095 + inputTag_.label() + ":" 00096 + inputTag_.instance() + ":" 00097 + inputTag_.process() + " are not found."; 00098 00099 IgDataStorage *storage = config->storage (); 00100 IgCollection &collection = storage->getCollection ("Error_V1"); 00101 IgProperty ERROR_MSG = collection.addProperty ("Error", std::string ()); 00102 IgCollectionItem item = collection.create (); 00103 item [ERROR_MSG] = error; 00104 } 00105 } 00106 00107 DEFINE_FWK_MODULE(VisSiPixelCluster);