CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
FWDTDigiProxyBuilder.cc
Go to the documentation of this file.
1 /*
2  * FWDTDigiProxyBuilder.cc
3  * FWorks
4  *
5  * Created by Ianna Osborne on 6/7/10.
6  *
7  */
8 
9 #include "TEveGeoNode.h"
10 #include "TEvePointSet.h"
11 #include "TEveCompound.h"
12 #include "TGeoArb8.h"
13 #include "TEveBox.h"
14 
19 
21 
22 namespace
23 {
24  void
25  addTube( TEveBox* shape, const FWGeometry::GeomDetInfo& info, float localPos[3], const float* pars )
26  {
27  const Float_t width = pars[0] / 2.;
28  const Float_t thickness = pars[1] / 2.;
29  const Float_t length = pars[2] / 2.;
30 
31  const Float_t vtx[24] = { localPos[0] - width, -length, -thickness,
32  localPos[0] - width, length, -thickness,
33  localPos[0] + width, length, -thickness,
34  localPos[0] + width, -length, -thickness,
35  localPos[0] - width, -length, thickness,
36  localPos[0] - width, length, thickness,
37  localPos[0] + width, length, thickness,
38  localPos[0] + width, -length, thickness };
39 
40  double array[16] = { info.matrix[0], info.matrix[3], info.matrix[6], 0.,
41  info.matrix[1], info.matrix[4], info.matrix[7], 0.,
42  info.matrix[2], info.matrix[5], info.matrix[8], 0.,
43  info.translation[0], info.translation[1], info.translation[2], 1.
44  };
45 
46  shape->SetVertices( vtx );
47  shape->SetTransMatrix( array );
48  shape->SetDrawFrame(false);
49  shape->SetMainTransparency( 75 );
50  }
51 }
52 
54 {
55 public:
57  virtual ~FWDTDigiProxyBuilder( void ) {}
58 
59  virtual bool haveSingleProduct( void ) const override { return false; }
60 
62 
63 private:
64  // Disable default copy constructor
66  // Disable default assignment operator
68 
69  virtual void buildViewType( const FWEventItem* iItem, TEveElementList* product, FWViewType::EType, const FWViewContext* ) override;
70 };
71 
72 void
73 FWDTDigiProxyBuilder::buildViewType( const FWEventItem* iItem, TEveElementList* product, FWViewType::EType type, const FWViewContext* )
74 {
75  const DTDigiCollection* digis = 0;
76  iItem->get( digis );
77 
78  if( ! digis )
79  {
80  return;
81  }
82  const FWGeometry *geom = iItem->getGeom();
83 
84  for( DTDigiCollection::DigiRangeIterator dri = digis->begin(), dre = digis->end(); dri != dre; ++dri )
85  {
86  const DTLayerId& layerId = (*dri).first;
87  unsigned int rawid = layerId.rawId();
88  const DTDigiCollection::Range &range = (*dri).second;
89 
90  if( ! geom->contains( rawid ))
91  {
92  fwLog( fwlog::kWarning ) << "failed to get geometry of DT with detid: "
93  << rawid << std::endl;
94 
95  TEveCompound* compound = createCompound();
96  setupAddElement( compound, product );
97 
98  continue;
99  }
100 
101  const float* pars = geom->getParameters( rawid );
102  FWGeometry::IdToInfoItr det = geom->find( rawid );
103 
104  int superLayer = layerId.superlayerId().superLayer();
105 
106  float localPos[3] = { 0.0, 0.0, 0.0 };
107 
108  // Loop over the digis of this DetUnit
109  for( DTDigiCollection::const_iterator it = range.first;
110  it != range.second; ++it )
111  {
112  // The x wire position in the layer, starting from its wire number.
113  float firstChannel = pars[3];
114  float nChannels = pars[5];
115  localPos[0] = ((*it).wire() - ( firstChannel - 1 ) - 0.5 ) * pars[0] - nChannels / 2.0 * pars[0];
116 
117  if( type == FWViewType::k3D || type == FWViewType::kISpy )
118  {
119  TEveBox* box = new TEveBox;
120  setupAddElement( box, product );
121  ::addTube( box, *det, localPos, pars );
122  }
123  else if(( ( type == FWViewType::kRhoPhi || type == FWViewType::kRhoPhiPF ) && superLayer != 2 ) ||
124  ( type == FWViewType::kRhoZ && superLayer == 2 ))
125  {
126  TEvePointSet* pointSet = new TEvePointSet;
127  pointSet->SetMarkerStyle( 24 );
128  setupAddElement( pointSet, product);
129 
130  float globalPos[3];
131  geom->localToGlobal( *det, localPos, globalPos );
132  pointSet->SetNextPoint( globalPos[0], globalPos[1], globalPos[2] );
133 
134  TEveBox* box = new TEveBox;
135  setupAddElement( box, product );
136  ::addTube( box, *det, localPos, pars );
137  }
138  else
139  {
140  TEveCompound* compound = createCompound();
141  setupAddElement( compound, product );
142 
143  }
144  }
145  }
146 }
147 
type
Definition: HCALResponse.h:21
virtual void buildViewType(const FWEventItem *iItem, TEveElementList *product, FWViewType::EType, const FWViewContext *) override
static const TGPicture * info(bool iBackgroundIsBlack)
#define REGISTER_FWPROXYBUILDER(_name_, _type_, _purpose_, _view_)
static const int kAllRPZBits
Definition: FWViewType.h:58
IdToInfoItr find(unsigned int) const
Definition: FWGeometry.cc:355
const float * getParameters(unsigned int id) const
Definition: FWGeometry.cc:293
void setupAddElement(TEveElement *el, TEveElement *parent, bool set_color=true) const
void get(const T *&oData) const
Definition: FWEventItem.h:84
DTSuperLayerId superlayerId() const
Return the corresponding SuperLayerId.
Definition: DTLayerId.h:59
static const int kAll3DBits
Definition: FWViewType.h:59
uint32_t rawId() const
get the raw id
Definition: DetId.h:43
void localToGlobal(unsigned int id, const float *local, float *global, bool translatep=true) const
Definition: FWGeometry.cc:325
int superLayer() const
Return the superlayer number.
bool contains(unsigned int id) const
Definition: FWGeometry.h:98
#define fwLog(_level_)
Definition: fwLog.h:50
std::vector< DTDigi >::const_iterator const_iterator
const FWDTDigiProxyBuilder & operator=(const FWDTDigiProxyBuilder &)
TEveCompound * createCompound(bool set_color=true, bool propagate_color_to_all_children=false) const
std::pair< const_iterator, const_iterator > Range
std::vector< FWGeometry::GeomDetInfo >::const_iterator IdToInfoItr
Definition: FWGeometry.h:96
const FWGeometry * getGeom() const
Definition: FWEventItem.cc:681
virtual bool haveSingleProduct(void) const override
virtual ~FWDTDigiProxyBuilder(void)