File indexing completed on 2023-10-25 09:40:07
0001 #ifndef DeDxHitInfo_H
0002 #define DeDxHitInfo_H
0003 #include <vector>
0004
0005 #include "DataFormats/DetId/interface/DetId.h"
0006 #include "DataFormats/SiStripDetId/interface/SiStripDetId.h"
0007 #include "DataFormats/SiStripCluster/interface/SiStripCluster.h"
0008 #include "DataFormats/SiPixelCluster/interface/SiPixelCluster.h"
0009 #include "DataFormats/GeometryVector/interface/LocalPoint.h"
0010 #include "DataFormats/Common/interface/Association.h"
0011 #include "DataFormats/Common/interface/RefVector.h"
0012
0013 namespace reco {
0014 class DeDxHitInfo {
0015 public:
0016 class DeDxHitInfoContainer {
0017 public:
0018 DeDxHitInfoContainer() : charge_(0.0f), pathlength_(0.0f) {}
0019 DeDxHitInfoContainer(const float charge, const float pathlength, const DetId& detId, const LocalPoint& pos)
0020 : charge_(charge), pathlength_(pathlength), detId_(detId), pos_(pos) {}
0021
0022 float charge() const { return charge_; }
0023 float pathlength() const { return pathlength_; }
0024 const DetId& detId() const { return detId_; }
0025 const LocalPoint& pos() const { return pos_; }
0026
0027 private:
0028
0029 float charge_;
0030
0031 float pathlength_;
0032 DetId detId_;
0033
0034 LocalPoint pos_;
0035 };
0036
0037 typedef std::vector<DeDxHitInfo::DeDxHitInfoContainer> DeDxHitInfoContainerCollection;
0038
0039 public:
0040 DeDxHitInfo() {}
0041 size_t size() const { return infos_.size(); }
0042 float charge(size_t i) const { return infos_[i].charge(); }
0043 float pathlength(size_t i) const { return infos_[i].pathlength(); }
0044 DetId detId(size_t i) const { return infos_[i].detId(); }
0045 const LocalPoint pos(size_t i) const { return infos_[i].pos(); }
0046 const SiPixelCluster* pixelCluster(size_t i) const {
0047 size_t P = 0;
0048 bool isPixel = false;
0049 bool isFirst = true;
0050 for (size_t j = 0; j <= i && j < infos_.size(); j++) {
0051 if (detId(j).subdetId() < SiStripDetId::TIB) {
0052 if (isFirst)
0053 isFirst = false;
0054 else
0055 P++;
0056 isPixel = true;
0057 } else {
0058 isPixel = false;
0059 }
0060 }
0061 if (isPixel && pixelClusters_.size() > P) {
0062 return &(pixelClusters_[P]);
0063 }
0064 return nullptr;
0065 }
0066 const SiStripCluster* stripCluster(size_t i) const {
0067 size_t S = 0;
0068 bool isStrip = false;
0069 bool isFirst = true;
0070 for (size_t j = 0; j <= i && j < infos_.size(); j++) {
0071 if (detId(j).subdetId() >= SiStripDetId::TIB) {
0072 if (isFirst) {
0073 isFirst = false;
0074 } else
0075 S++;
0076 isStrip = true;
0077 } else {
0078 isStrip = false;
0079 }
0080 }
0081 if (isStrip && stripClusters_.size() > S) {
0082 return &(stripClusters_[S]);
0083 }
0084 return nullptr;
0085 }
0086 const std::vector<SiStripCluster>& stripClusters() const { return stripClusters_; }
0087 const std::vector<SiPixelCluster>& pixelClusters() const { return pixelClusters_; }
0088
0089 void addHit(const float charge,
0090 const float pathlength,
0091 const DetId& detId,
0092 const LocalPoint& pos,
0093 const SiStripCluster& stripCluster) {
0094 infos_.push_back(DeDxHitInfoContainer(charge, pathlength, detId, pos));
0095 stripClusters_.push_back(stripCluster);
0096 }
0097 void addHit(const float charge,
0098 const float pathlength,
0099 const DetId& detId,
0100 const LocalPoint& pos,
0101 const SiPixelCluster& pixelCluster) {
0102 infos_.push_back(DeDxHitInfoContainer(charge, pathlength, detId, pos));
0103 pixelClusters_.push_back(pixelCluster);
0104 }
0105
0106 private:
0107 std::vector<DeDxHitInfoContainer> infos_;
0108 std::vector<SiStripCluster> stripClusters_;
0109 std::vector<SiPixelCluster> pixelClusters_;
0110 };
0111
0112 typedef std::vector<DeDxHitInfo> DeDxHitInfoCollection;
0113 typedef edm::Ref<DeDxHitInfoCollection> DeDxHitInfoRef;
0114 typedef edm::RefProd<DeDxHitInfoCollection> DeDxHitInfoRefProd;
0115 typedef edm::RefVector<DeDxHitInfoCollection> DeDxHitInfoRefVector;
0116 typedef edm::Association<DeDxHitInfoCollection> DeDxHitInfoAss;
0117 }
0118
0119 #endif