#include <VisReco/Analyzer/interface/VisSiPixelRecHit.h>
Public Member Functions | |
virtual void | analyze (const edm::Event &, const edm::EventSetup &) |
VisSiPixelRecHit (const edm::ParameterSet &iPSet) | |
virtual | ~VisSiPixelRecHit (void) |
Private Attributes | |
edm::InputTag | inputTag_ |
Definition at line 18 of file VisSiPixelRecHit.h.
VisSiPixelRecHit::VisSiPixelRecHit | ( | const edm::ParameterSet & | iPSet | ) | [explicit] |
Definition at line 32 of file VisSiPixelRecHit.cc.
00033 : inputTag_ (iConfig.getParameter<edm::InputTag>("visSiPixelRecHitTag")) 00034 {}
virtual VisSiPixelRecHit::~VisSiPixelRecHit | ( | void | ) | [inline, virtual] |
void VisSiPixelRecHit::analyze | ( | const edm::Event & | event, | |
const edm::EventSetup & | eventSetup | |||
) | [virtual] |
Implements edm::EDAnalyzer.
Definition at line 37 of file VisSiPixelRecHit.cc.
References IgCollection::addProperty(), collection, edmplugin::standard::config(), IgCollection::create(), error, Exception, edm::EventSetup::get(), IgDataStorage::getCollection(), inputTag_, edm::InputTag::instance(), edm::Service< T >::isAvailable(), edm::Handle< T >::isValid(), edm::ESHandle< T >::isValid(), edm::InputTag::label(), edm::InputTag::process(), range, DetId::rawId(), PV3DBase< T, PVType, FrameType >::x(), PV3DBase< T, PVType, FrameType >::y(), and PV3DBase< T, PVType, FrameType >::z().
00038 { 00039 edm::Service<IguanaService> config; 00040 if (! config.isAvailable ()) 00041 { 00042 throw cms::Exception ("Configuration") 00043 << "VisSiPixelRecHit 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<SiPixelRecHitCollection> 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 &rechits = storage->getCollection ("SiPixelRecHits_V1"); 00059 IgProperty DET_ID = rechits.addProperty ("detid", int (0)); 00060 IgProperty POS = rechits.addProperty ("pos", IgV3d()); 00061 00062 #ifdef CMSSW_2_2_X 00063 00064 SiPixelRecHitCollection::id_iterator detUnitIt; 00065 for (detUnitIt = collection->id_begin(); detUnitIt != collection->id_end(); ++detUnitIt) 00066 { 00067 SiPixelRecHitCollection::range range = collection->get((*detUnitIt)); 00068 for (SiPixelRecHitCollection::const_iterator ipixel = range.first; ipixel != range.second; ++ipixel) 00069 { 00070 DetId detectorId = (*ipixel).geographicalId (); 00071 unsigned int id = detectorId.rawId (); 00072 00073 DetId detid (id); 00074 00075 if((*ipixel).hasPositionAndError ()) 00076 { 00077 LocalPoint position = (*ipixel).localPosition (); 00078 00079 GlobalPoint pos = geom->idToDet (detid)->surface ().toGlobal (position); 00080 00081 IgCollectionItem item = rechits.create (); 00082 item[DET_ID] = static_cast<int> (id); 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 for (SiPixelRecHitCollection::DataContainer::const_iterator ipixel = collection->data ().begin (), ipixelEnd = collection->data ().end (); 00090 ipixel != ipixelEnd; ++ipixel) 00091 { 00092 DetId detectorId = (*ipixel).geographicalId (); 00093 unsigned int id = detectorId.rawId (); 00094 00095 DetId detid (id); 00096 00097 if((*ipixel).hasPositionAndError ()) 00098 { 00099 LocalPoint position = (*ipixel).localPosition (); 00100 00101 GlobalPoint pos = geom->idToDet (detid)->surface ().toGlobal (position); 00102 00103 IgCollectionItem item = rechits.create (); 00104 item[DET_ID] = static_cast<int> (id); 00105 item[POS] = IgV3d(static_cast<double>(pos.x()/100.0), static_cast<double>(pos.y()/100.0), static_cast<double>(pos.z()/100.0)); 00106 } 00107 } 00108 #endif 00109 00110 } 00111 else 00112 { 00113 // friendlyName:moduleLabel:instanceName:processName 00114 std::string error = "### Error: SiPixel RecHits " 00115 + edm::TypeID (typeid (SiPixelRecHitCollection)).friendlyClassName () + ":" 00116 + inputTag_.label() + ":" 00117 + inputTag_.instance() + ":" 00118 + inputTag_.process() + " are not found."; 00119 00120 IgDataStorage *storage = config->storage (); 00121 IgCollection &collection = storage->getCollection ("Errors_V1"); 00122 IgProperty ERROR_MSG = collection.addProperty ("Error", std::string ()); 00123 IgCollectionItem item = collection.create (); 00124 item [ERROR_MSG] = error; 00125 } 00126 }
edm::InputTag VisSiPixelRecHit::inputTag_ [private] |