CMS 3D CMS Logo

FWPFEcalRecHitLegoProxyBuilder.cc
Go to the documentation of this file.
2 
3 //______________________________________________________________________________
4 void
6 {
7  FWViewEnergyScale *caloScale = vc->getEnergyScale();
8  bool b = caloScale->getPlotEt();
9  float maxVal = getMaxVal( b );
10  typedef std::vector<FWPFLegoRecHit*> rh;
11 
12  // printf("FWPFEcalRecHitLegoProxyBuilder::scaleProduct >> scale %f \n", caloScale->getValToHeight());
13  for( rh::iterator i = m_recHits.begin(); i != m_recHits.end(); ++i )
14  { // Tallest tower needs deciding still
15  if( (*i)->isTallest() == false && (*i)->getEtEnergy( b ) == maxVal )
16  (*i)->setIsTallest( true );
17 
18  (*i)->updateScale( vc, getMaxValLog(caloScale->getPlotEt()));
19  }
20 }
21 
22 //______________________________________________________________________________
23 void
25  FWViewType::EType viewType, const FWViewContext *vc )
26 {
27  for (TEveElement::List_i i = parent->BeginChildren(); i!= parent->EndChildren(); ++i)
28  {
29  {
30  TEveStraightLineSet* line = dynamic_cast<TEveStraightLineSet*>(*i);
31  if (line)
32  {
33  line->SetMarkerColor( item()->modelInfo( iId.index() ).displayProperties().color() );
34  }
35  }
36  }
37 }
38 
39 //______________________________________________________________________________
40 TEveVector
41 FWPFEcalRecHitLegoProxyBuilder::calculateCentre( const std::vector<TEveVector> &corners ) const
42 {
43  TEveVector centre;
44 
45  for( size_t i = 0; i < corners.size(); ++i )
46  {
47  centre.fX += corners[i].fX;
48  centre.fY += corners[i].fY; // Get total for x,y,z values
49  centre.fZ += corners[i].fZ;
50  }
51  centre *= 1.f / 8.f;
52 
53  return centre;
54 }
55 
56 //______________________________________________________________________________
57 void
58 FWPFEcalRecHitLegoProxyBuilder::build( const FWEventItem *iItem, TEveElementList *product, const FWViewContext *vc )
59 {
60  size_t itemSize = iItem->size(); //cache size
61 
62  for( size_t index = 0; index < itemSize; ++index )
63  {
64  TEveCompound *itemHolder = createCompound();
65  product->AddElement( itemHolder );
66 
67  const EcalRecHit &iData = modelData( index );
68  const float *corners = item()->getGeom()->getCorners( iData.detid() );
69  float energy, et;
70  std::vector<TEveVector> etaphiCorners(8);
71  TEveVector centre;
72 
73  if( corners == nullptr )
74  continue;
75 
76  int k = 3;
77  for( int i = 0; i < 4; ++i )
78  {
79  int j = k * 3;
80  TEveVector cv = TEveVector( corners[j], corners[j+1], corners[j+2] );
81  etaphiCorners[i].fX = cv.Eta(); // Conversion of rechit X/Y values for plotting in Eta/Phi
82  etaphiCorners[i].fY = cv.Phi();
83  etaphiCorners[i].fZ = 0.0;
84 
85  etaphiCorners[i+4].fX = etaphiCorners[i].fX; // Top can simply be plotted exactly over the top of the bottom face
86  etaphiCorners[i+4].fY = etaphiCorners[i].fY;
87  etaphiCorners[i+4].fZ = 0.001;
88  // printf("%f %f %d \n", etaphiCorners[i].fX, etaphiCorners[i].fY, i);
89  --k;
90  }
91 
92  centre = calculateCentre( etaphiCorners );
93  energy = iData.energy();
94  et = FWPFMaths::calculateEt( centre, energy );
95  context().voteMaxEtAndEnergy( et, energy );
96 
97  if( energy > m_maxEnergy )
98  m_maxEnergy = energy;
99  if( energy > m_maxEt )
100  m_maxEt = et;
101 
102  // Stop phi wrap
103  float dPhi1 = etaphiCorners[2].fY - etaphiCorners[1].fY;
104  float dPhi2 = etaphiCorners[3].fY - etaphiCorners[0].fY;
105  float dPhi3 = etaphiCorners[1].fY - etaphiCorners[2].fY;
106  float dPhi4 = etaphiCorners[0].fY - etaphiCorners[3].fY;
107 
108  if( dPhi1 > 1 )
109  etaphiCorners[2].fY = etaphiCorners[2].fY - ( 2 * TMath::Pi() );
110  if( dPhi2 > 1 )
111  etaphiCorners[3].fY = etaphiCorners[3].fY - ( 2 * TMath::Pi() );
112  if( dPhi3 > 1 )
113  etaphiCorners[2].fY = etaphiCorners[2].fY + ( 2 * TMath::Pi() );
114  if( dPhi4 > 1 )
115  etaphiCorners[3].fY = etaphiCorners[3].fY + ( 2 * TMath::Pi() );
116 
117  FWPFLegoRecHit *recHit = new FWPFLegoRecHit( etaphiCorners, itemHolder, this, vc, energy, et );
118  recHit->setSquareColor( item()->defaultDisplayProperties().color() );
119  m_recHits.push_back( recHit );
120  }
121 
123  m_maxEtLog = log( m_maxEt );
124 
125  scaleProduct( product, FWViewType::kLegoPFECAL, vc );
126 }
127 
128 //______________________________________________________________________________
129 void
131 {
132  for( std::vector<FWPFLegoRecHit*>::iterator i = m_recHits.begin(); i != m_recHits.end(); ++i )
133  delete (*i);
134 
135  m_recHits.clear();
136 }
137 
138 //______________________________________________________________________________
const double Pi
type
Definition: HCALResponse.h:21
const fireworks::Context & context() const
#define REGISTER_FWPROXYBUILDER(_name_, _type_, _purpose_, _view_)
TEveVector calculateCentre(const std::vector< TEveVector > &corners) const
void voteMaxEtAndEnergy(float Et, float energy) const
Definition: Context.cc:183
FWViewEnergyScale * getEnergyScale() const
const DetId & detid() const
Definition: EcalRecHit.h:72
cv
Definition: cuy.py:364
const FWEventItem * item() const
const EcalRecHit & modelData(int index)
void scaleProduct(TEveElementList *parent, FWViewType::EType, const FWViewContext *vc) override
int index() const
Definition: FWModelId.h:49
float energy() const
Definition: EcalRecHit.h:68
void setSquareColor(Color_t c)
float calculateEt(const TEveVector &centre, float e)
Definition: FWPFMaths.cc:115
int k[5][pyjets_maxn]
const float * getCorners(unsigned int id) const
Definition: FWGeometry.cc:430
size_t size() const
Definition: FWEventItem.cc:553
double b
Definition: hdecay.h:120
et
define resolution functions of each parameter
TEveCompound * createCompound(bool set_color=true, bool propagate_color_to_all_children=false) const
std::vector< FWPFLegoRecHit * > m_recHits
const FWGeometry * getGeom() const
Definition: FWEventItem.cc:686
void localModelChanges(const FWModelId &iId, TEveElement *iCompound, FWViewType::EType viewType, const FWViewContext *vc) override
bool getPlotEt() const