Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2021-08-03 04:10:04

0001 #include "Fireworks/Core/interface/FWSimpleProxyBuilderTemplate.h"
0002 #include "Fireworks/Core/interface/Context.h"
0003 #include "Fireworks/Core/interface/FWGeometry.h"
0004 #include "SimDataFormats/CaloAnalysis/interface/CaloParticle.h"
0005 #include "SimDataFormats/CaloAnalysis/interface/CaloParticleFwd.h"
0006 #include "SimDataFormats/CaloAnalysis/interface/SimCluster.h"
0007 
0008 #include "TEveBoxSet.h"
0009 
0010 class FWECaloParticleProxyBuilder : public FWSimpleProxyBuilderTemplate<CaloParticle> {
0011 public:
0012   FWECaloParticleProxyBuilder(void) {}
0013   ~FWECaloParticleProxyBuilder(void) override {}
0014 
0015   REGISTER_PROXYBUILDER_METHODS();
0016 
0017   // Disable default copy constructor
0018   FWECaloParticleProxyBuilder(const FWECaloParticleProxyBuilder &) = delete;
0019   // Disable default assignment operator
0020   const FWECaloParticleProxyBuilder &operator=(const FWECaloParticleProxyBuilder &) = delete;
0021 
0022 private:
0023   void build(const CaloParticle &iData, unsigned int iIndex, TEveElement &oItemHolder, const FWViewContext *) override;
0024 };
0025 
0026 void FWECaloParticleProxyBuilder::build(const CaloParticle &iData,
0027                                         unsigned int iIndex,
0028                                         TEveElement &oItemHolder,
0029                                         const FWViewContext *) {
0030   TEveBoxSet *boxset = new TEveBoxSet();
0031   boxset->UseSingleColor();
0032   boxset->SetPickable(true);
0033   boxset->Reset(TEveBoxSet::kBT_FreeBox, true, 64);
0034   boxset->SetAntiFlick(true);
0035 
0036   for (const auto &c : iData.simClusters()) {
0037     for (const auto &it : (*c).hits_and_fractions()) {
0038       if (DetId(it.first).det() != DetId::Detector::Ecal) {
0039         std::cerr << "this proxy should be used only for ECAL";
0040         return;
0041       }
0042 
0043       const float *corners = item()->getGeom()->getCorners(it.first);
0044       if (corners == nullptr)
0045         continue;
0046 
0047       boxset->AddBox(corners);
0048     }
0049   }
0050 
0051   boxset->RefitPlex();
0052   boxset->CSCTakeAnyParentAsMaster();
0053   boxset->CSCApplyMainColorToMatchingChildren();
0054   boxset->CSCApplyMainTransparencyToMatchingChildren();
0055   boxset->SetMainColor(item()->modelInfo(iIndex).displayProperties().color());
0056   boxset->SetMainTransparency(item()->defaultDisplayProperties().transparency());
0057   oItemHolder.AddElement(boxset);
0058 }
0059 
0060 REGISTER_FWPROXYBUILDER(FWECaloParticleProxyBuilder,
0061                         CaloParticle,
0062                         "ECaloParticle",
0063                         FWViewType::kAll3DBits | FWViewType::kAllRPZBits);