00001 //<<<<<< INCLUDES >>>>>> 00002 00003 #include "VisReco/Analyzer/interface/VisSiStripCluster.h" 00004 #include "VisReco/Analyzer/interface/IguanaService.h" 00005 #include "DataFormats/Common/interface/DetSetVectorNew.h" 00006 #include "DataFormats/SiStripCluster/interface/SiStripCluster.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/CommonTopologies/interface/StripTopology.h" 00016 #include "Geometry/TrackerGeometryBuilder/interface/StripGeomDetUnit.h" 00017 #include "Geometry/TrackerGeometryBuilder/interface/TrackerGeometry.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 VisSiStripCluster::VisSiStripCluster (const edm::ParameterSet& iConfig) 00034 : inputTag_ (iConfig.getParameter<edm::InputTag>("visSiStripClusterTag")) 00035 {} 00036 00037 void 00038 VisSiStripCluster::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 << "VisSiStripCluster 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<SiStripCluster> > 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 ("SiStripClusters_V1"); 00060 IgProperty DET_ID = clusters.addProperty ("detid", int (0)); 00061 IgProperty POS = clusters.addProperty ("pos", IgV3d()); 00062 00063 edmNew::DetSetVector<SiStripCluster>::const_iterator it = collection->begin (); 00064 edmNew::DetSetVector<SiStripCluster>::const_iterator end = collection->end (); 00065 00066 for (; it != end; ++it) 00067 { 00068 edmNew::DetSet<SiStripCluster> ds = *it; 00069 const uint32_t detID = it->detId (); 00070 DetId detid (detID); 00071 00072 const StripGeomDetUnit* theDet = dynamic_cast<const StripGeomDetUnit *>(geom->idToDet (detid)); 00073 const StripTopology* theTopol = dynamic_cast<const StripTopology *>( &(theDet->specificTopology ())); 00074 00075 edmNew::DetSet<SiStripCluster>::const_iterator icluster = it->begin (); 00076 edmNew::DetSet<SiStripCluster>::const_iterator iclusterEnd = it->end (); 00077 00078 for(; icluster != iclusterEnd; ++icluster) 00079 { 00080 short firststrip = (*icluster).firstStrip (); 00081 GlobalPoint pos = (geom->idToDet (detid))->surface().toGlobal (theTopol->localPosition (firststrip)); 00082 IgCollectionItem item = clusters.create (); 00083 item[DET_ID] = static_cast<int> (detID); 00084 item[POS] = IgV3d(static_cast<double>(pos.x()/100.0), static_cast<double>(pos.y()/100.0), static_cast<double>(pos.z()/100.0)); 00085 } 00086 } 00087 } 00088 else 00089 { 00090 // friendlyName:moduleLabel:instanceName:processName 00091 std::string error = "### Error: SiStrip Clusters " 00092 + edm::TypeID (typeid (edmNew::DetSetVector<SiStripCluster>)).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(VisSiStripCluster);