Back to home page

Project CMSSW displayed by LXR

 
 

    


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

0001 // -*- C++ -*-
0002 //
0003 // Package:     Photons
0004 // Class  :     FWPhotonProxyBuilder
0005 //
0006 // Implementation:
0007 //     <Notes on implementation>
0008 //
0009 // Original Author:  Chris Jones
0010 //         Created:  Wed Nov 26 14:52:01 EST 2008
0011 //
0012 
0013 #include "TEveBoxSet.h"
0014 
0015 #include "Fireworks/Core/interface/fwLog.h"
0016 #include "Fireworks/Core/interface/FWSimpleProxyBuilderTemplate.h"
0017 #include "Fireworks/Core/interface/FWEventItem.h"
0018 #include "Fireworks/Core/interface/FWViewType.h"
0019 #include "Fireworks/Electrons/interface/makeSuperCluster.h"
0020 
0021 #include "DataFormats/EgammaCandidates/interface/Photon.h"
0022 
0023 #include "Fireworks/Core/interface/FWGeometry.h"
0024 
0025 class FWPhotonProxyBuilder : public FWSimpleProxyBuilderTemplate<reco::Photon> {
0026 public:
0027   FWPhotonProxyBuilder(void) {}
0028 
0029   ~FWPhotonProxyBuilder(void) override {}
0030 
0031   bool haveSingleProduct(void) const override { return false; }
0032 
0033   REGISTER_PROXYBUILDER_METHODS();
0034 
0035   FWPhotonProxyBuilder(const FWPhotonProxyBuilder&) = delete;
0036   const FWPhotonProxyBuilder& operator=(const FWPhotonProxyBuilder&) = delete;
0037 
0038 private:
0039   using FWSimpleProxyBuilderTemplate<reco::Photon>::buildViewType;
0040   void buildViewType(const reco::Photon& photon,
0041                      unsigned int iIndex,
0042                      TEveElement& oItemHolder,
0043                      FWViewType::EType type,
0044                      const FWViewContext*) override;
0045 };
0046 
0047 void FWPhotonProxyBuilder::buildViewType(const reco::Photon& photon,
0048                                          unsigned int iIndex,
0049                                          TEveElement& oItemHolder,
0050                                          FWViewType::EType type,
0051                                          const FWViewContext*) {
0052   const FWGeometry* geom = item()->getGeom();
0053 
0054   if (type == FWViewType::kRhoPhi || type == FWViewType::kRhoPhiPF) {
0055     fireworks::makeRhoPhiSuperCluster(this, photon.superCluster(), photon.phi(), oItemHolder);
0056   }
0057 
0058   else if (type == FWViewType::kRhoZ)
0059     fireworks::makeRhoZSuperCluster(this, photon.superCluster(), photon.phi(), oItemHolder);
0060 
0061   else if (type == FWViewType::kISpy) {
0062     std::vector<std::pair<DetId, float> > detIds = photon.superCluster()->hitsAndFractions();
0063 
0064     TEveBoxSet* boxset = new TEveBoxSet();
0065     boxset->Reset(TEveBoxSet::kBT_FreeBox, true, 64);
0066     boxset->UseSingleColor();
0067     boxset->SetPickable(true);
0068 
0069     for (std::vector<std::pair<DetId, float> >::iterator id = detIds.begin(), ide = detIds.end(); id != ide; ++id) {
0070       const float* corners = geom->getCorners(id->first.rawId());
0071 
0072       if (corners == nullptr) {
0073         fwLog(fwlog::kWarning) << "No corners available for supercluster constituent" << std::endl;
0074         continue;
0075       }
0076       boxset->AddBox(&corners[0]);
0077     }
0078 
0079     boxset->RefitPlex();
0080     setupAddElement(boxset, &oItemHolder);
0081   }
0082 }
0083 
0084 REGISTER_FWPROXYBUILDER(FWPhotonProxyBuilder, reco::Photon, "Photons", FWViewType::kAllRPZBits | FWViewType::kAll3DBits);