CMS 3D CMS Logo

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  ~FWDTDigiProxyBuilder( void ) override {}
58 
59  bool haveSingleProduct( void ) const override { return false; }
60 
62 
63 private:
64  // Disable default copy constructor
65  FWDTDigiProxyBuilder( const FWDTDigiProxyBuilder& ) = delete;
66  // Disable default assignment operator
67  const FWDTDigiProxyBuilder& operator=( const FWDTDigiProxyBuilder& ) = delete;
68 
70  void buildViewType( const FWEventItem* iItem, TEveElementList* product, FWViewType::EType, const FWViewContext* ) override;
71 };
72 
73 void
74 FWDTDigiProxyBuilder::buildViewType( const FWEventItem* iItem, TEveElementList* product, FWViewType::EType type, const FWViewContext* )
75 {
76  const DTDigiCollection* digis = nullptr;
77  iItem->get( digis );
78 
79  if( ! digis )
80  {
81  return;
82  }
83  const FWGeometry *geom = iItem->getGeom();
84 
85  for( DTDigiCollection::DigiRangeIterator dri = digis->begin(), dre = digis->end(); dri != dre; ++dri )
86  {
87  const DTLayerId& layerId = (*dri).first;
88  unsigned int rawid = layerId.rawId();
89  const DTDigiCollection::Range &range = (*dri).second;
90 
91  if( ! geom->contains( rawid ))
92  {
93  fwLog( fwlog::kWarning ) << "failed to get geometry of DT with detid: "
94  << rawid << std::endl;
95 
96  TEveCompound* compound = createCompound();
97  setupAddElement( compound, product );
98 
99  continue;
100  }
101 
102  const float* pars = geom->getParameters( rawid );
103  FWGeometry::IdToInfoItr det = geom->find( rawid );
104 
105  int superLayer = layerId.superlayerId().superLayer();
106 
107  float localPos[3] = { 0.0, 0.0, 0.0 };
108 
109  // Loop over the digis of this DetUnit
110  for( DTDigiCollection::const_iterator it = range.first;
111  it != range.second; ++it )
112  {
113  // The x wire position in the layer, starting from its wire number.
114  float firstChannel = pars[3];
115  float nChannels = pars[5];
116  localPos[0] = ((*it).wire() - ( firstChannel - 1 ) - 0.5 ) * pars[0] - nChannels / 2.0 * pars[0];
117 
118  if( type == FWViewType::k3D || type == FWViewType::kISpy )
119  {
120  TEveBox* box = new TEveBox;
121  setupAddElement( box, product );
122  ::addTube( box, *det, localPos, pars );
123  }
124  else if(( ( type == FWViewType::kRhoPhi || type == FWViewType::kRhoPhiPF ) && superLayer != 2 ) ||
125  ( type == FWViewType::kRhoZ && superLayer == 2 ))
126  {
127  TEvePointSet* pointSet = new TEvePointSet;
128  pointSet->SetMarkerStyle( 24 );
129  setupAddElement( pointSet, product);
130 
131  float globalPos[3];
132  geom->localToGlobal( *det, localPos, globalPos );
133  pointSet->SetNextPoint( globalPos[0], globalPos[1], globalPos[2] );
134 
135  TEveBox* box = new TEveBox;
136  setupAddElement( box, product );
137  ::addTube( box, *det, localPos, pars );
138  }
139  else
140  {
141  TEveCompound* compound = createCompound();
142  setupAddElement( compound, product );
143 
144  }
145  }
146  }
147 }
148 
type
Definition: HCALResponse.h:21
virtual void buildViewType(const FWEventItem *iItem, TEveElementList *, FWViewType::EType, const FWViewContext *)
void buildViewType(const FWEventItem *iItem, TEveElementList *product, FWViewType::EType, const FWViewContext *) override
#define REGISTER_PROXYBUILDER_METHODS()
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:364
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
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
~FWDTDigiProxyBuilder(void) override
void localToGlobal(unsigned int id, const float *local, float *global, bool translatep=true) const
Definition: FWGeometry.cc:334
int superLayer() const
Return the superlayer number.
const FWDTDigiProxyBuilder & operator=(const FWDTDigiProxyBuilder &)=delete
bool contains(unsigned int id) const
Definition: FWGeometry.h:110
#define fwLog(_level_)
Definition: fwLog.h:50
std::vector< DTDigi >::const_iterator const_iterator
TEveCompound * createCompound(bool set_color=true, bool propagate_color_to_all_children=false) const
std::pair< const_iterator, const_iterator > Range
bool haveSingleProduct(void) const override
std::vector< FWGeometry::GeomDetInfo >::const_iterator IdToInfoItr
Definition: FWGeometry.h:107
const FWGeometry * getGeom() const
Definition: FWEventItem.cc:683