File indexing completed on 2024-04-06 12:11:27
0001
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012
0013
0014
0015
0016 #include "TEveVector.h"
0017 #include "TEveCaloData.h"
0018 #include "TH2F.h"
0019
0020 #include "Fireworks/Calo/plugins/FWHFTowerSliceSelector.h"
0021 #include "Fireworks/Core/interface/FWModelChangeManager.h"
0022 #include "Fireworks/Core/interface/FWEventItem.h"
0023 #include "Fireworks/Core/interface/FWGeometry.h"
0024 #include "Fireworks/Core/interface/fwLog.h"
0025 #include "DataFormats/HcalRecHit/interface/HFRecHit.h"
0026 #include "DataFormats/HcalRecHit/interface/HcalRecHitCollections.h"
0027
0028
0029
0030
0031
0032 void FWHFTowerSliceSelector::doSelect(const TEveCaloData::CellId_t& iCell) {
0033 if (!m_item)
0034 return;
0035
0036 const HFRecHitCollection* hits = nullptr;
0037 m_item->get(hits);
0038 assert(nullptr != hits);
0039
0040 int index = 0;
0041 FWChangeSentry sentry(*(m_item->changeManager()));
0042 for (HFRecHitCollection::const_iterator it = hits->begin(); it != hits->end(); ++it, ++index) {
0043 HcalDetId id((*it).detid().rawId());
0044 if (findBinFromId(id, iCell.fTower) && m_item->modelInfo(index).m_displayProperties.isVisible() &&
0045 !m_item->modelInfo(index).isSelected()) {
0046
0047 m_item->select(index);
0048 }
0049 }
0050 }
0051
0052 void FWHFTowerSliceSelector::doUnselect(const TEveCaloData::CellId_t& iCell) {
0053 if (!m_item)
0054 return;
0055
0056 const HFRecHitCollection* hits = nullptr;
0057 m_item->get(hits);
0058 assert(nullptr != hits);
0059
0060 int index = 0;
0061 FWChangeSentry sentry(*(m_item->changeManager()));
0062 for (HFRecHitCollection::const_iterator it = hits->begin(); it != hits->end(); ++it, ++index) {
0063 HcalDetId id((*it).detid().rawId());
0064 if (findBinFromId(id, iCell.fTower) && m_item->modelInfo(index).m_displayProperties.isVisible() &&
0065 m_item->modelInfo(index).isSelected()) {
0066
0067 m_item->unselect(index);
0068 }
0069 }
0070 }
0071
0072 bool FWHFTowerSliceSelector::findBinFromId(HcalDetId& detId, int tower) const {
0073 TEveCaloData::vCellId_t cellIds;
0074 const float* corners = m_item->getGeom()->getCorners(detId.rawId());
0075 if (corners == nullptr) {
0076 fwLog(fwlog::kInfo) << "FWHFTowerSliceSelector cannot get geometry for DetId: " << detId.rawId() << ". Ignored.\n";
0077 return false;
0078 }
0079 std::vector<TEveVector> front(4);
0080 float eta = 0, phi = 0;
0081 int j = 0;
0082 for (int i = 0; i < 4; ++i) {
0083 front[i] = TEveVector(corners[j], corners[j + 1], corners[j + 2]);
0084 j += 3;
0085
0086 eta += front[i].Eta();
0087 phi += front[i].Phi();
0088 }
0089 eta /= 4;
0090 phi /= 4;
0091
0092 const TEveCaloData::CellGeom_t& cg = m_vecData->GetCellGeom()[tower];
0093 if ((eta >= cg.fEtaMin && eta <= cg.fEtaMax) && (phi >= cg.fPhiMin && phi <= cg.fPhiMax)) {
0094 return true;
0095 }
0096
0097 return false;
0098 }