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  const FWDisplayProperties &p = item()->modelInfo( iId.index() ).displayProperties();
34  line->SetMarkerColor( p.color() );
35  }
36  }
37  }
38 }
39 
40 //______________________________________________________________________________
41 TEveVector
42 FWPFEcalRecHitLegoProxyBuilder::calculateCentre( const std::vector<TEveVector> &corners ) const
43 {
44  TEveVector centre;
45 
46  for( size_t i = 0; i < corners.size(); ++i )
47  {
48  centre.fX += corners[i].fX;
49  centre.fY += corners[i].fY; // Get total for x,y,z values
50  centre.fZ += corners[i].fZ;
51  }
52  centre *= 1.f / 8.f;
53 
54  return centre;
55 }
56 
57 //______________________________________________________________________________
58 void
59 FWPFEcalRecHitLegoProxyBuilder::build( const FWEventItem *iItem, TEveElementList *product, const FWViewContext *vc )
60 {
61  size_t itemSize = iItem->size(); //cache size
62 
63  for( size_t index = 0; index < itemSize; ++index )
64  {
65  TEveCompound *itemHolder = createCompound();
66  product->AddElement( itemHolder );
67 
68  const EcalRecHit &iData = modelData( index );
69  const float *corners = item()->getGeom()->getCorners( iData.detid() );
70  float energy, et;
71  std::vector<TEveVector> etaphiCorners(8);
72  TEveVector centre;
73 
74  if( corners == 0 )
75  continue;
76 
77  int k = 3;
78  for( int i = 0; i < 4; ++i )
79  {
80  int j = k * 3;
81  TEveVector cv = TEveVector( corners[j], corners[j+1], corners[j+2] );
82  etaphiCorners[i].fX = cv.Eta(); // Conversion of rechit X/Y values for plotting in Eta/Phi
83  etaphiCorners[i].fY = cv.Phi();
84  etaphiCorners[i].fZ = 0.0;
85 
86  etaphiCorners[i+4].fX = etaphiCorners[i].fX; // Top can simply be plotted exactly over the top of the bottom face
87  etaphiCorners[i+4].fY = etaphiCorners[i].fY;
88  etaphiCorners[i+4].fZ = 0.001;
89  // printf("%f %f %d \n", etaphiCorners[i].fX, etaphiCorners[i].fY, i);
90  --k;
91  }
92 
93  centre = calculateCentre( etaphiCorners );
94  energy = iData.energy();
95  et = FWPFMaths::calculateEt( centre, energy );
96  context().voteMaxEtAndEnergy( et, energy );
97 
98  if( energy > m_maxEnergy )
99  m_maxEnergy = energy;
100  if( energy > m_maxEt )
101  m_maxEt = et;
102 
103  // Stop phi wrap
104  float dPhi1 = etaphiCorners[2].fY - etaphiCorners[1].fY;
105  float dPhi2 = etaphiCorners[3].fY - etaphiCorners[0].fY;
106  float dPhi3 = etaphiCorners[1].fY - etaphiCorners[2].fY;
107  float dPhi4 = etaphiCorners[0].fY - etaphiCorners[3].fY;
108 
109  if( dPhi1 > 1 )
110  etaphiCorners[2].fY = etaphiCorners[2].fY - ( 2 * TMath::Pi() );
111  if( dPhi2 > 1 )
112  etaphiCorners[3].fY = etaphiCorners[3].fY - ( 2 * TMath::Pi() );
113  if( dPhi3 > 1 )
114  etaphiCorners[2].fY = etaphiCorners[2].fY + ( 2 * TMath::Pi() );
115  if( dPhi4 > 1 )
116  etaphiCorners[3].fY = etaphiCorners[3].fY + ( 2 * TMath::Pi() );
117 
118  FWPFLegoRecHit *recHit = new FWPFLegoRecHit( etaphiCorners, itemHolder, this, vc, energy, et );
119  recHit->setSquareColor( item()->defaultDisplayProperties().color() );
120  m_recHits.push_back( recHit );
121  }
122 
124  m_maxEtLog = log( m_maxEt );
125 
126  scaleProduct( product, FWViewType::kLegoPFECAL, vc );
127 }
128 
129 //______________________________________________________________________________
130 void
132 {
133  for( std::vector<FWPFLegoRecHit*>::iterator i = m_recHits.begin(); i != m_recHits.end(); ++i )
134  delete (*i);
135 
136  m_recHits.clear();
137 }
138 
139 //______________________________________________________________________________
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
virtual void scaleProduct(TEveElementList *parent, FWViewType::EType, const FWViewContext *vc)
cv
Definition: cuy.py:362
const FWEventItem * item() const
const EcalRecHit & modelData(int index)
Color_t color() const
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
virtual void localModelChanges(const FWModelId &iId, TEveElement *iCompound, FWViewType::EType viewType, const FWViewContext *vc)
int k[5][pyjets_maxn]
const float * getCorners(unsigned int id) const
Definition: FWGeometry.cc:286
size_t size() const
Definition: FWEventItem.cc:550
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
ModelInfo modelInfo(int iIndex) const
Definition: FWEventItem.cc:537
std::vector< FWPFLegoRecHit * > m_recHits
const FWGeometry * getGeom() const
Definition: FWEventItem.cc:683
bool getPlotEt() const