CMS 3D CMS Logo

FWCaloParticleProxyBuilder.cc
Go to the documentation of this file.
1 /*
2  * FWCaloParticleProxyBuilder.cc
3  * FWorks
4  *
5  * Created by Marco Rovere 13/09/2018
6  *
7  */
8 
16 
19 
20 #include "TEveTrack.h"
21 #include "TEveBoxSet.h"
22 
24 {
25 public:
27  ~FWCaloParticleProxyBuilder( void ) override {}
28 
29  void setItem(const FWEventItem* iItem) override {
31  iItem->getConfig()->assertParam("Point Size", 1l, 3l, 1l);
32  }
33 
35 
36 private:
37  // Disable default copy constructor
39  // Disable default assignment operator
41 
43  void build( const CaloParticle& iData, unsigned int iIndex, TEveElement& oItemHolder, const FWViewContext* ) override;
44 };
45 
46 void
47 FWCaloParticleProxyBuilder::build( const CaloParticle& iData, unsigned int iIndex, TEveElement& oItemHolder, const FWViewContext* )
48 {
49  TEveRecTrack t;
50  t.fBeta = 1.0;
51  t.fP = TEveVector( iData.px(), iData.py(), iData.pz() );
52  t.fV = TEveVector( iData.g4Tracks()[0].trackerSurfacePosition().x(),
53  iData.g4Tracks()[0].trackerSurfacePosition().y(),
54  iData.g4Tracks()[0].trackerSurfacePosition().z() );
55  t.fSign = iData.charge();
56 
57  TEveTrack* track = new TEveTrack(&t, context().getTrackPropagator());
58  if( t.fSign == 0 )
59  track->SetLineStyle( 7 );
60 
61  track->MakeTrack();
62  setupAddElement( track, &oItemHolder );
63  TEveBoxSet* boxset = new TEveBoxSet();
64  boxset->Reset(TEveBoxSet::kBT_FreeBox, true, 64);
65  boxset->UseSingleColor();
66  boxset->SetPickable(true);
67  for (const auto & c : iData.simClusters())
68  {
69  auto clusterDetIds = (*c).hits_and_fractions();
70 
71 
72  for( auto it = clusterDetIds.begin(), itEnd = clusterDetIds.end();
73  it != itEnd; ++it )
74  {
75  const float* corners = item()->getGeom()->getCorners( (*it).first );
76  if( corners == nullptr ) {
77  continue;
78  }
79  std::vector<float> pnts(24);
80  fireworks::energyTower3DCorners(corners, (*it).second, pnts);
81  boxset->AddBox( &pnts[0]);
82  }
83  }
84  boxset->RefitPlex();
85  setupAddElement(boxset, &oItemHolder);
86 }
87 
float pz() const
z coordinate of momentum vector. Note this is taken from the first SimTrack only. ...
Definition: CaloParticle.h:146
void setItem(const FWEventItem *iItem) override
const fireworks::Context & context() const
FWProxyBuilderConfiguration * getConfig() const
Definition: FWEventItem.h:169
#define REGISTER_PROXYBUILDER_METHODS()
#define REGISTER_FWPROXYBUILDER(_name_, _type_, _purpose_, _view_)
static const int kAllRPZBits
Definition: FWViewType.h:58
void setupAddElement(TEveElement *el, TEveElement *parent, bool set_color=true) const
float charge() const
Electric charge. Note this is taken from the first SimTrack only.
Definition: CaloParticle.h:81
const FWCaloParticleProxyBuilder & operator=(const FWCaloParticleProxyBuilder &)=delete
const std::vector< SimTrack > & g4Tracks() const
Definition: CaloParticle.h:76
const FWEventItem * item() const
static const int kAll3DBits
Definition: FWViewType.h:59
const SimClusterRefVector & simClusters() const
Definition: CaloParticle.h:74
virtual void setItem(const FWEventItem *iItem)
FWGenericParameter< T > * assertParam(const std::string &name, T def)
void energyTower3DCorners(const float *corners, float scale, std::vector< float > &, bool reflect=false)
const float * getCorners(unsigned int id) const
Definition: FWGeometry.cc:297
float px() const
x coordinate of momentum vector. Note this is taken from the first SimTrack only. ...
Definition: CaloParticle.h:136
float py() const
y coordinate of momentum vector. Note this is taken from the first SimTrack only. ...
Definition: CaloParticle.h:141
const FWGeometry * getGeom() const
Definition: FWEventItem.cc:683