Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015 #include "TEveStraightLineSet.h"
00016 #include "TEveCompound.h"
00017 #include "TEveGeoNode.h"
00018
00019 #include "Fireworks/Core/interface/FWProxyBuilderBase.h"
00020 #include "Fireworks/Core/interface/FWEventItem.h"
00021 #include "Fireworks/Core/interface/FWGeometry.h"
00022 #include "Fireworks/Core/interface/fwLog.h"
00023
00024 #include "DataFormats/GEMDigi/interface/GEMDigiCollection.h"
00025
00026 class FWGEMDigiProxyBuilder : public FWProxyBuilderBase
00027 {
00028 public:
00029 FWGEMDigiProxyBuilder() {}
00030 virtual ~FWGEMDigiProxyBuilder() {}
00031
00032 REGISTER_PROXYBUILDER_METHODS();
00033
00034 private:
00035 virtual void build(const FWEventItem* iItem, TEveElementList* product, const FWViewContext*);
00036 FWGEMDigiProxyBuilder(const FWGEMDigiProxyBuilder&);
00037 const FWGEMDigiProxyBuilder& operator=(const FWGEMDigiProxyBuilder&);
00038 };
00039
00040 void
00041 FWGEMDigiProxyBuilder::build(const FWEventItem* iItem, TEveElementList* product, const FWViewContext*)
00042 {
00043 const GEMDigiCollection* digis = 0;
00044
00045 iItem->get(digis);
00046
00047 if ( ! digis )
00048 {
00049 fwLog(fwlog::kWarning)<<"Failed to get GEMDigis"<<std::endl;
00050 return;
00051 }
00052 const FWGeometry *geom = iItem->getGeom();
00053
00054 for ( GEMDigiCollection::DigiRangeIterator dri = digis->begin(), driEnd = digis->end();
00055 dri != driEnd; ++dri )
00056 {
00057 unsigned int rawid = (*dri).first.rawId();
00058 const GEMDigiCollection::Range& range = (*dri).second;
00059
00060 if( ! geom->contains( rawid ))
00061 {
00062 fwLog( fwlog::kWarning ) << "Failed to get geometry of GEM roll with detid: "
00063 << rawid << std::endl;
00064
00065 TEveCompound* compound = createCompound();
00066 setupAddElement( compound, product );
00067
00068 continue;
00069 }
00070
00071 const float* parameters = geom->getParameters( rawid );
00072 float nStrips = parameters[0];
00073 float halfStripLength = parameters[1]*0.5;
00074 float pitch = parameters[2];
00075 float offset = -0.5*nStrips*pitch;
00076
00077 for( GEMDigiCollection::const_iterator dit = range.first;
00078 dit != range.second; ++dit )
00079 {
00080 TEveStraightLineSet* stripDigiSet = new TEveStraightLineSet;
00081 stripDigiSet->SetLineWidth(3);
00082 setupAddElement( stripDigiSet, product );
00083
00084 int strip = (*dit).strip();
00085 float centreOfStrip = (strip-0.5)*pitch + offset;
00086
00087 float localPointTop[3] =
00088 {
00089 centreOfStrip, halfStripLength, 0.0
00090 };
00091
00092 float localPointBottom[3] =
00093 {
00094 centreOfStrip, -halfStripLength, 0.0
00095 };
00096
00097 float globalPointTop[3];
00098 float globalPointBottom[3];
00099
00100 geom->localToGlobal( rawid, localPointTop, globalPointTop, localPointBottom, globalPointBottom );
00101
00102 stripDigiSet->AddLine(globalPointTop[0], globalPointTop[1], globalPointTop[2],
00103 globalPointBottom[0], globalPointBottom[1], globalPointBottom[2]);
00104 }
00105 }
00106 }
00107
00108 REGISTER_FWPROXYBUILDER(FWGEMDigiProxyBuilder, GEMDigiCollection, "GEMDigi",
00109 FWViewType::kAll3DBits | FWViewType::kAllRPZBits);
00110