Skip to content

Commit

Permalink
Revert "GeneralInterpretation (cms-sw#19)"
Browse files Browse the repository at this point in the history
This reverts commit 3416ad8.
  • Loading branch information
waredjeb committed Jan 2, 2024
1 parent 45bfcfb commit bf67fa0
Show file tree
Hide file tree
Showing 42 changed files with 277 additions and 1,352 deletions.
104 changes: 59 additions & 45 deletions CommonTools/RecoAlgos/interface/MultiVectorManager.h
Original file line number Diff line number Diff line change
Expand Up @@ -10,70 +10,84 @@
template <typename T>
class MultiVectorManager {
public:
void addVector(const std::vector<T>& vec) {
vectors.emplace_back(vec.begin(), vec.end());
offsets.push_back(totalSize);
totalSize += vec.size();
}
void addVector(const std::vector<T>& vec) {
vectors.emplace_back(vec.begin(), vec.end());
offsets.push_back(totalSize);
totalSize += vec.size();
}

T& operator[](size_t globalIndex) {
return const_cast<T&>(static_cast<const MultiVectorManager*>(this)->operator[](globalIndex));
}
T& operator[](size_t globalIndex) {
return const_cast<T&>(static_cast<const MultiVectorManager*>(this)->operator[](globalIndex));
}

const T& operator[](size_t globalIndex) const {
assert(globalIndex < totalSize && "Global index out of range");
const T& operator[](size_t globalIndex) const {
assert(globalIndex < totalSize && "Global index out of range");

auto it = std::upper_bound(offsets.begin(), offsets.end(), globalIndex);
size_t vectorIndex = std::distance(offsets.begin(), it) - 1;
size_t localIndex = globalIndex - offsets[vectorIndex];
auto it = std::upper_bound(offsets.begin(), offsets.end(), globalIndex);
size_t vectorIndex = std::distance(offsets.begin(), it) - 1;
size_t localIndex = globalIndex - offsets[vectorIndex];

return vectors[vectorIndex][localIndex];
}
return vectors[vectorIndex][localIndex];
}

size_t getGlobalIndex(size_t vectorIndex, size_t localIndex) const {
assert(vectorIndex < vectors.size() && "Vector index out of range");
size_t getGlobalIndex(size_t vectorIndex, size_t localIndex) const {
assert(vectorIndex < vectors.size() && "Vector index out of range");

const auto& vec = vectors[vectorIndex];
assert(localIndex < vec.size() && "Local index out of range");
const auto& vec = vectors[vectorIndex];
assert(localIndex < vec.size() && "Local index out of range");

return offsets[vectorIndex] + localIndex;
}
return offsets[vectorIndex] + localIndex;
}

size_t size() const { return totalSize; }
size_t size() const {
return totalSize;
}

std::pair<size_t, size_t> getVectorAndLocalIndex(size_t globalIndex) const {
assert(globalIndex < totalSize && "Global index out of range");
std::pair<size_t, size_t> getVectorAndLocalIndex(size_t globalIndex) const {
assert(globalIndex < totalSize && "Global index out of range");

auto it = std::upper_bound(offsets.begin(), offsets.end(), globalIndex);
size_t vectorIndex = std::distance(offsets.begin(), it) - 1;
size_t localIndex = globalIndex - offsets[vectorIndex];
auto it = std::upper_bound(offsets.begin(), offsets.end(), globalIndex);
size_t vectorIndex = std::distance(offsets.begin(), it) - 1;
size_t localIndex = globalIndex - offsets[vectorIndex];

return {vectorIndex, localIndex};
}
return {vectorIndex, localIndex};
}

class Iterator {
public:
Iterator(const MultiVectorManager& manager, size_t index) : manager(manager), currentIndex(index) {}
class Iterator {
public:
Iterator(const MultiVectorManager& manager, size_t index)
: manager(manager), currentIndex(index) {}

bool operator!=(const Iterator& other) const { return currentIndex != other.currentIndex; }
bool operator!=(const Iterator& other) const {
return currentIndex != other.currentIndex;
}

T& operator*() const { return const_cast<T&>(manager[currentIndex]); }
T& operator*() const {
return const_cast<T&>(manager[currentIndex]);
}

void operator++() { ++currentIndex; }
void operator++() {
++currentIndex;
}

private:
const MultiVectorManager& manager;
size_t currentIndex;
};
private:
const MultiVectorManager& manager;
size_t currentIndex;
};

Iterator begin() const { return Iterator(*this, 0); }
Iterator begin() const {
return Iterator(*this, 0);
}

Iterator end() const { return Iterator(*this, totalSize); }
Iterator end() const {
return Iterator(*this, totalSize);
}

private:
std::vector<std::vector<T>> vectors;
std::vector<size_t> offsets;
size_t totalSize = 0;
std::vector<std::vector<T>> vectors;
std::vector<size_t> offsets;
size_t totalSize = 0;
};

#endif

#endif
70 changes: 9 additions & 61 deletions DataFormats/HGCalReco/interface/TICLCandidate.h
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
#include "DataFormats/Math/interface/Point3D.h"
#include "DataFormats/TrackReco/interface/Track.h"
#include "DataFormats/TrackReco/interface/TrackFwd.h"
#include "RecoHGCal/TICL/interface/commons.h"

// A TICLCandidate is a lightweight physics object made from one or multiple Tracksters.

Expand All @@ -16,68 +15,17 @@ class TICLCandidate : public reco::LeafCandidate {
typedef ticl::Trackster::ParticleType ParticleType;

TICLCandidate(Charge q, const LorentzVector& p4)
: LeafCandidate(q, p4), idProbabilities_{}, time_(0.f), timeError_(-1.f), rawEnergy_(0.f) {}
: LeafCandidate(q, p4), time_(0.f), timeError_(-1.f), rawEnergy_(0.f), idProbabilities_{} {}

TICLCandidate() : LeafCandidate(), idProbabilities_{}, time_(0.f), timeError_(-1.f), rawEnergy_(0.f) {}
TICLCandidate() : LeafCandidate(), time_(0.f), timeError_(-1.f), rawEnergy_(0.f), idProbabilities_{} {}

TICLCandidate(const edm::Ptr<ticl::Trackster>& trackster)
: LeafCandidate(),
idProbabilities_{},
tracksters_({trackster}),
time_(trackster->time()),
timeError_(trackster->timeError()),
rawEnergy_(0.f) {}

TICLCandidate(const edm::Ptr<reco::Track> trackPtr, edm::Ptr<ticl::Trackster>& tracksterPtr)
: LeafCandidate(),
tracksters_({std::move(tracksterPtr)}),
trackPtr_(std::move(trackPtr)),
time_(0.f),
timeError_(-1.f) {
//TODO: Raise Error
assert(trackPtr_.isNonnull() or tracksters_[0].isNonnull());

if (tracksters_[0].isNonnull()) {
auto const& trackster = tracksters_[0].get();
idProbabilities_ = trackster->id_probabilities();
if (trackPtr_.isNonnull()) {
auto pdgId = trackster->isHadronic() ? 211 : 11;
auto const& tk = trackPtr_.get();
setPdgId(pdgId * tk->charge());
setCharge(tk->charge());
rawEnergy_ = trackster->raw_energy();
auto const& regrE = trackster->regressed_energy();
math::XYZTLorentzVector p4(regrE * tk->momentum().unit().x(),
regrE * tk->momentum().unit().y(),
regrE * tk->momentum().unit().z(),
regrE);
setP4(p4);

} else {
auto pdgId = trackster->isHadronic() ? 130 : 22;
setPdgId(pdgId);
setCharge(0);
rawEnergy_ = trackster->raw_energy();
const float& regrE = trackster->regressed_energy();
math::XYZTLorentzVector p4(regrE * trackster->barycenter().unit().x(),
regrE * trackster->barycenter().unit().y(),
regrE * trackster->barycenter().unit().z(),
regrE);
setP4(p4);
}
}

else {
//candidate from track only
auto const& tk = trackPtr_.get();
setPdgId(211 * tk->charge());
setCharge(tk->charge());
const float energy = std::sqrt(tk->p() * tk->p() + ticl::mpion2);
setRawEnergy(energy);
math::PtEtaPhiMLorentzVector p4Polar(tk->pt(), tk->eta(), tk->phi(), ticl::mpion);
setP4(p4Polar);
}
}
rawEnergy_(0.f),
tracksters_({trackster}),
idProbabilities_{} {}

inline float time() const { return time_; }
inline float timeError() const { return timeError_; }
Expand Down Expand Up @@ -117,17 +65,17 @@ class TICLCandidate : public reco::LeafCandidate {
inline void setIdProbability(ParticleType type, float value) { idProbabilities_[int(type)] = value; }

private:
std::array<float, 8> idProbabilities_;
std::vector<edm::Ptr<ticl::Trackster> > tracksters_;
edm::Ptr<reco::Track> trackPtr_;

float time_;
float timeError_;
edm::Ptr<reco::Track> trackPtr_;

float rawEnergy_;

// vector of Ptr so Tracksters can come from different collections
// and there can be derived classes
std::vector<edm::Ptr<ticl::Trackster> > tracksters_;

// Since it contains multiple tracksters, duplicate the probability interface
std::array<float, 8> idProbabilities_;
};
#endif
4 changes: 3 additions & 1 deletion DataFormats/HGCalReco/interface/TICLLayerTile.h
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,9 @@ class TICLLayerTileT {
public:
typedef T type;

void fill(float eta, float phi, unsigned int layerClusterId) { tile_[globalBin(eta, phi)].push_back(layerClusterId); }
void fill(float eta, float phi, unsigned int layerClusterId) {
tile_[globalBin(eta, phi)].push_back(layerClusterId);
}

int etaBin(float eta) const {
constexpr float etaRange = T::maxEta - T::minEta;
Expand Down
23 changes: 11 additions & 12 deletions DataFormats/HGCalReco/interface/Trackster.h
Original file line number Diff line number Diff line change
Expand Up @@ -74,23 +74,20 @@ namespace ticl {
inline void setBarycenter(Vector value) { barycenter_ = value; }
inline void setTrackIdx(int index) { track_idx_ = index; }
int trackIdx() const { return track_idx_; }
inline bool isHadronic(float th = 0.5f) const {
return id_probability(Trackster::ParticleType::photon) + id_probability(Trackster::ParticleType::electron) < th;
}
inline void mergeTracksters(const Trackster &other) {
inline void mergeTracksters(const Trackster& other){
*this += other;

//remove duplicates
//remove duplicates
removeDuplicates();
zeroProbabilities();
}

inline void mergeTracksters(const std::vector<Trackster> &others) {
for (auto &other : others) {
inline void mergeTracksters(const std::vector<Trackster>& others){
for(auto& other: others){
*this += other;
}

//remove duplicates
//remove duplicates
removeDuplicates();
zeroProbabilities();
}
Expand Down Expand Up @@ -225,12 +222,14 @@ namespace ticl {
auto iDup = std::find(std::next(firstEl), vertices_.end(), lcIdx);
while (iDup != vertices_.end()) {
vertices_.erase(iDup);
vertex_multiplicity_.erase(vertex_multiplicity_.begin() + std::distance(std::begin(vertices_), iDup));
vertex_multiplicity_.erase(vertex_multiplicity_.begin() +
std::distance(std::begin(vertices_), iDup));
vertex_multiplicity_[firstPos] -= 1;
iDup = std::find(std::next(firstEl), vertices_.end(), lcIdx);
};
}
}
}

}
inline void operator+=(const Trackster &other) {
// use getters on other
Expand All @@ -240,9 +239,9 @@ namespace ticl {
raw_em_pt_ += other.raw_em_pt();
// add vertices and multiplicities
std::copy(std::begin(other.vertices()), std::end(other.vertices()), std::back_inserter(vertices_));
std::copy(std::begin(other.vertex_multiplicity()),
std::end(other.vertex_multiplicity()),
std::copy(std::begin(other.vertex_multiplicity()), std::end(other.vertex_multiplicity()),
std::back_inserter(vertex_multiplicity_));

}
};

Expand Down
3 changes: 1 addition & 2 deletions DataFormats/HGCalReco/src/classes_def.xml
Original file line number Diff line number Diff line change
Expand Up @@ -51,8 +51,7 @@
<class name="edm::Wrapper<TICLSeedingRegion>" />
<class name="edm::Wrapper<std::vector<TICLSeedingRegion> >" />

<class name="TICLCandidate" ClassVersion="4">
<version ClassVersion="4" checksum="3155265136"/>
<class name="TICLCandidate" ClassVersion="3">
<version ClassVersion="3" checksum="450468662"/>
</class>
<class name="std::vector<TICLCandidate>" />
Expand Down
3 changes: 0 additions & 3 deletions DataFormats/TrackReco/src/classes_def.xml
Original file line number Diff line number Diff line change
Expand Up @@ -513,7 +513,4 @@
<class name="std::vector<SeedStopInfo>" persistent="false"/>
<class name="edm::Wrapper<std::vector<SeedStopInfo> >" persistent="false"/>

<class name="edm::ValueMap<Point3DBase<float,GlobalTag> >"/>
<class name="edm::Wrapper<edm::ValueMap<Point3DBase<float,GlobalTag> > >"/>

</lcgdict>
4 changes: 2 additions & 2 deletions Fireworks/Calo/plugins/FWCaloClusterProxyBuilder.cc
Original file line number Diff line number Diff line change
Expand Up @@ -114,8 +114,8 @@ void FWCaloClusterProxyBuilder::build(const reco::CaloCluster &iData,
continue;

// HGCal
if (iData.algo() == reco::CaloCluster::hgcal_em || iData.algo() == reco::CaloCluster::hgcal_had ||
iData.algo() == reco::CaloCluster::hgcal_scintillator || (type >= 8 && type <= 10)) {
if (iData.algo() == reco::CaloCluster::hgcal_em || iData.algo() == reco::CaloCluster::hgcal_had || iData.algo() == reco::CaloCluster::hgcal_scintillator ||
(type >= 8 && type <= 10)) {
if (heatmap && hitmap->find(it->first) == hitmap->end())
continue;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import FWCore.ParameterSet.Config as cms
from RecoLocalCalo.HGCalRecProducers.HGCalUncalibRecHitProducer_cfi import HGCalUncalibRecHitProducer

HGCalUncalibRecHitL1Seeded = HGCalUncalibRecHitProducer.clone(
HGCalUncalibRecHitL1Seeded = cms.EDProducer("HGCalUncalibRecHitProducer",
HGCEEConfig = cms.PSet(
adcNbits = cms.uint32(10),
adcSaturation = cms.double(100),
Expand All @@ -14,6 +13,7 @@
toaLSB_ns = cms.double(0.0244)
),
HGCEEdigiCollection = cms.InputTag("hgcalDigisL1Seeded","EE"),
HGCEEhitCollection = cms.string('HGCEEUncalibRecHits'),
HGCHEBConfig = cms.PSet(
adcNbits = cms.uint32(10),
adcSaturation = cms.double(68.75),
Expand All @@ -26,6 +26,7 @@
toaLSB_ns = cms.double(0.0244)
),
HGCHEBdigiCollection = cms.InputTag("hgcalDigisL1Seeded","HEback"),
HGCHEBhitCollection = cms.string('HGCHEBUncalibRecHits'),
HGCHEFConfig = cms.PSet(
adcNbits = cms.uint32(10),
adcSaturation = cms.double(100),
Expand All @@ -38,6 +39,7 @@
toaLSB_ns = cms.double(0.0244)
),
HGCHEFdigiCollection = cms.InputTag("hgcalDigisL1Seeded","HEfront"),
HGCHEFhitCollection = cms.string('HGCHEFUncalibRecHits'),
HGCHFNoseConfig = cms.PSet(
adcNbits = cms.uint32(10),
adcSaturation = cms.double(100),
Expand All @@ -48,5 +50,8 @@
tdcSaturation = cms.double(10000),
tofDelay = cms.double(-33),
toaLSB_ns = cms.double(0.0244)
)
),
HGCHFNosedigiCollection = cms.InputTag("hfnoseDigis","HFNose"),
HGCHFNosehitCollection = cms.string('HGCHFNoseUncalibRecHits'),
algo = cms.string('HGCalUncalibRecHitWorkerWeights')
)
Loading

0 comments on commit bf67fa0

Please sign in to comment.