CMS 3D CMS Logo

FWSiPixelClusterProxyBuilder.cc
Go to the documentation of this file.
1 
2 // -*- C++ -*-
3 //
4 // Package: Tracks
5 // Class : FWSiPixelClusterProxyBuilder
6 //
7 //
8 // Original Author:
9 // Created: Thu Dec 6 18:01:21 PST 2007
10 //
11 
12 #include "TEvePointSet.h"
13 #include "TEveStraightLineSet.h"
14 #include "TEveCompound.h"
15 #include "TEveBox.h"
21 
23 
25 {
26 public:
28  virtual ~FWSiPixelClusterProxyBuilder( void ) {}
29 
31 
32 private:
33  // Disable default copy constructor
35  // Disable default assignment operator
37 
39  virtual void build( const FWEventItem* iItem, TEveElementList* product, const FWViewContext* ) override;
40 };
41 
42 void
43 FWSiPixelClusterProxyBuilder::build( const FWEventItem* iItem, TEveElementList* product , const FWViewContext* )
44 {
45  const SiPixelClusterCollectionNew* pixels = 0;
46 
47  iItem->get( pixels );
48 
49  if( ! pixels )
50  {
51  fwLog( fwlog::kWarning ) << "failed get SiPixelDigis" << std::endl;
52  return;
53  }
54 
55  for( SiPixelClusterCollectionNew::const_iterator set = pixels->begin(), setEnd = pixels->end();
56  set != setEnd; ++set )
57  {
58  unsigned int id = set->detId();
59 
60  const FWGeometry *geom = iItem->getGeom();
61  const float* pars = geom->getParameters( id );
62 
64 
65  for( edmNew::DetSet<SiPixelCluster>::const_iterator itc = clusters.begin(), edc = clusters.end();
66  itc != edc; ++itc )
67  {
68  TEveElement* itemHolder = createCompound();
69  product->AddElement(itemHolder);
70 
71  TEvePointSet* pointSet = new TEvePointSet;
72 
73  if( ! geom->contains( id ))
74  {
76  << "failed get geometry of SiPixelCluster with detid: "
77  << id << std::endl;
78  continue;
79  }
80 
81  float localPoint[3] =
82  {
83  fireworks::pixelLocalX(( *itc ).minPixelRow(), pars ),
84  fireworks::pixelLocalY(( *itc ).minPixelCol(), pars ),
85  0.0
86  };
87 
88  float globalPoint[3];
89  geom->localToGlobal( id, localPoint, globalPoint );
90 
91  pointSet->SetNextPoint( globalPoint[0], globalPoint[1], globalPoint[2] );
92 
93  setupAddElement( pointSet, itemHolder );
94 
95  TEveStraightLineSet* ls = new TEveStraightLineSet();
96  for(int j=0;j< (*itc).size(); j++ )
97  {
98 
99  // float adc= (*itc).pixel(j).adc*0.03/5000.;
100  float adc= 0.025;
101  float offsetx[4] = {-0.4,-0.4,+0.4,+0.4};
102  float offsety[4] = {-0.4,+0.4,+0.4,-0.4};
103  // float vert[24];
104 
105  std::vector<TEveVector> boxCorners;
106  for(int of=0;of<8;of++) {
107  float lp[3]= {
109  (*itc).pixel(j).x+offsetx[of%4], pars) ,
111  (*itc).pixel(j).y+offsety[of%4], pars ),
112  (of<4)?(0.0f):(adc)
113  };
114 
115  TEveVector p;
116  geom->localToGlobal( id,lp, p.Arr() );
117 
118  boxCorners.push_back(p);
119 
120  }
121 
122  // bottom
123  ls->AddLine(boxCorners[0], boxCorners[1]);
124  ls->AddLine(boxCorners[1], boxCorners[2]);
125  ls->AddLine(boxCorners[2], boxCorners[3]);
126  ls->AddLine(boxCorners[3], boxCorners[0]);
127  // top
128  ls->AddLine(boxCorners[4], boxCorners[5]);
129  ls->AddLine(boxCorners[5], boxCorners[6]);
130  ls->AddLine(boxCorners[6], boxCorners[7]);
131  ls->AddLine(boxCorners[7], boxCorners[4]);
132  // sides
133  ls->AddLine(boxCorners[0], boxCorners[4]);
134  ls->AddLine(boxCorners[1], boxCorners[5]);
135  ls->AddLine(boxCorners[2], boxCorners[6]);
136  ls->AddLine(boxCorners[3], boxCorners[7]);
137 
138 
139  }
140 
141  setupAddElement( ls, itemHolder );
142 
143  }
144  }
145 }
146 
int adc(sample_type sample)
get the ADC sample (12 bits)
boost::transform_iterator< IterHelp, const_IdIter > const_iterator
#define REGISTER_PROXYBUILDER_METHODS()
const_iterator end(bool update=false) const
#define REGISTER_FWPROXYBUILDER(_name_, _type_, _purpose_, _view_)
static const int kAllRPZBits
Definition: FWViewType.h:58
const float * getParameters(unsigned int id) const
Definition: FWGeometry.cc:302
void setupAddElement(TEveElement *el, TEveElement *parent, bool set_color=true) const
void get(const T *&oData) const
Definition: FWEventItem.h:85
data_type const * const_iterator
Definition: DetSetNew.h:30
static const int kAll3DBits
Definition: FWViewType.h:59
void localToGlobal(unsigned int id, const float *local, float *global, bool translatep=true) const
Definition: FWGeometry.cc:334
bool contains(unsigned int id) const
Definition: FWGeometry.h:110
float pixelLocalX(const double mpx, const float *)
Definition: TrackUtils.cc:166
float pixelLocalY(const double mpy, const float *)
Definition: TrackUtils.cc:222
def ls(path, rec=False)
Definition: eostools.py:348
#define fwLog(_level_)
Definition: fwLog.h:50
iterator end()
Definition: DetSetNew.h:70
TEveCompound * createCompound(bool set_color=true, bool propagate_color_to_all_children=false) const
const FWSiPixelClusterProxyBuilder & operator=(const FWSiPixelClusterProxyBuilder &)
const FWGeometry * getGeom() const
Definition: FWEventItem.cc:683
const_iterator begin(bool update=false) const
iterator begin()
Definition: DetSetNew.h:67