Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2024-04-06 12:11:45

0001 // -*- C++ -*-
0002 //
0003 // Package:     Electrons
0004 // Class  :     makeSuperCluster
0005 //
0006 // Implementation:
0007 //     <Notes on implementation>
0008 //
0009 // Original Author:  Chris Jones
0010 //         Created:  Fri Dec  5 15:32:33 EST 2008
0011 //
0012 
0013 // system include files
0014 #include "TEveGeoNode.h"
0015 #include "TEveGeoShape.h"
0016 #include "TGeoBBox.h"
0017 #include "TGeoTube.h"
0018 
0019 // user include files
0020 #include "Fireworks/Electrons/interface/makeSuperCluster.h"
0021 
0022 #include "Fireworks/Core/interface/BuilderUtils.h"
0023 #include "Fireworks/Core/interface/FWEventItem.h"
0024 #include "Fireworks/Core/interface/FWGeometry.h"
0025 #include "Fireworks/Core/interface/Context.h"
0026 #include "Fireworks/Core/interface/FWProxyBuilderBase.h"
0027 
0028 namespace fireworks {
0029   bool makeRhoPhiSuperCluster(FWProxyBuilderBase* pb,
0030                               const reco::SuperClusterRef& iCluster,
0031                               float iPhi,
0032                               TEveElement& oItemHolder) {
0033     if (!iCluster.isAvailable())
0034       return false;
0035     TEveGeoManagerHolder gmgr(TEveGeoShape::GetGeoMangeur());
0036 
0037     std::vector<std::pair<DetId, float> > detids = iCluster->hitsAndFractions();
0038     if (detids.empty())
0039       return false;
0040     std::vector<double> phis;
0041     for (std::vector<std::pair<DetId, float> >::const_iterator id = detids.begin(), end = detids.end(); id != end;
0042          ++id) {
0043       const float* corners = pb->context().getGeom()->getCorners(id->first.rawId());
0044       if (corners != nullptr) {
0045         std::vector<float> centre(3, 0);
0046 
0047         for (unsigned int i = 0; i < 24; i += 3) {
0048           centre[0] += corners[i];
0049           centre[1] += corners[i + 1];
0050           centre[2] += corners[i + 2];
0051         }
0052 
0053         phis.push_back(TEveVector(centre[0], centre[1], centre[2]).Phi());
0054       }
0055     }
0056     std::pair<double, double> phiRange = fireworks::getPhiRange(phis, iPhi);
0057     const double r = pb->context().caloR1();
0058     TGeoBBox* sc_box = new TGeoTubeSeg(r - 2,
0059                                        r,
0060                                        1,
0061                                        phiRange.first * 180 / M_PI - 0.5,
0062                                        phiRange.second * 180 / M_PI + 0.5);  // 0.5 is roughly half size of a crystal
0063     TEveGeoShape* sc = fireworks::getShape("supercluster", sc_box, pb->item()->defaultDisplayProperties().color());
0064     sc->SetPickable(kTRUE);
0065     pb->setupAddElement(sc, &oItemHolder);
0066     return true;
0067   }
0068 
0069   bool makeRhoZSuperCluster(FWProxyBuilderBase* pb,
0070                             const reco::SuperClusterRef& iCluster,
0071                             float iPhi,
0072                             TEveElement& oItemHolder) {
0073     if (!iCluster.isAvailable())
0074       return false;
0075     TEveGeoManagerHolder gmgr(TEveGeoShape::GetGeoMangeur());
0076     double theta_max = 0;
0077     double theta_min = 10;
0078     std::vector<std::pair<DetId, float> > detids = iCluster->hitsAndFractions();
0079     if (detids.empty())
0080       return false;
0081     for (std::vector<std::pair<DetId, float> >::const_iterator id = detids.begin(), end = detids.end(); id != end;
0082          ++id) {
0083       const float* corners = pb->context().getGeom()->getCorners(id->first.rawId());
0084       if (corners != nullptr) {
0085         std::vector<float> centre(3, 0);
0086 
0087         for (unsigned int i = 0; i < 24; i += 3) {
0088           centre[0] += corners[i];
0089           centre[1] += corners[i + 1];
0090           centre[2] += corners[i + 2];
0091         }
0092 
0093         double theta = TEveVector(centre[0], centre[1], centre[2]).Theta();
0094         if (theta > theta_max)
0095           theta_max = theta;
0096         if (theta < theta_min)
0097           theta_min = theta;
0098       }
0099     }
0100     // expand theta range by the size of a crystal to avoid segments of zero length
0101     bool barrel = true;
0102     if ((theta_max > 0 && theta_max < pb->context().caloTransAngle()) ||
0103         (theta_min > (TMath::Pi() - pb->context().caloTransAngle()))) {
0104       barrel = false;
0105     }
0106 
0107     double z_ecal = barrel ? pb->context().caloZ1() : pb->context().caloZ2();
0108     double r_ecal = barrel ? pb->context().caloR1() : pb->context().caloR2();
0109 
0110     fireworks::addRhoZEnergyProjection(
0111         pb, &oItemHolder, r_ecal - 1, z_ecal - 1, theta_min - 0.003, theta_max + 0.003, iPhi);
0112 
0113     return true;
0114   }
0115 
0116 }  // namespace fireworks