46 using CandidateToDuplicate = std::vector<std::pair<int, int>>;
50 using MVACollection = std::vector<float>;
51 using QualityMaskCollection = std::vector<unsigned char>;
97 desc.
add<
std::string>(
"trackAlgoPriorityOrder",
"trackAlgoPriorityOrder");
98 desc.
add<
int>(
"diffHitsCut", 5);
100 descriptions.
add(
"DuplicateListMerger", desc);
104 : collectionCloner(producesCollector(), iPara,
true),
105 mergedTrackSource_(iPara.getParameter<
edm::
InputTag>(
"mergedSource"), consumesCollector()),
106 originalTrackSource_(iPara.getParameter<
edm::
InputTag>(
"originalSource"), consumesCollector()),
107 priorityName_(iPara.getParameter<
std::
string>(
"trackAlgoPriorityOrder")) {
110 candidateComponents_ = consumes<CandidateToDuplicate>(iPara.getParameter<
edm::InputTag>(
"candidateComponents"));
112 mergedMVAValsToken_ = consumes<MVACollection>(iPara.getParameter<
edm::InputTag>(
"mergedMVAVals"));
113 originalMVAValsToken_ = consumes<MVACollection>(iPara.getParameter<
edm::InputTag>(
"originalMVAVals"));
115 produces<MVACollection>(
"MVAValues");
116 produces<QualityMaskCollection>(
"QualityMasks");
119 DuplicateListMerger::~DuplicateListMerger() {
125 auto const& originals = originalTrackSource_.tracks(iEvent);
126 auto const& merged = mergedTrackSource_.tracks(iEvent);
127 auto const& candIndices = mergedTrackSource_.indicesInput(iEvent);
130 iEvent.
getByToken(candidateSource_, candidateH);
134 iEvent.
getByToken(candidateComponents_, candidateComponentsH);
140 iEvent.
getByToken(originalMVAValsToken_, originalMVAStore);
141 iEvent.
getByToken(mergedMVAValsToken_, mergedMVAStore);
147 MVACollection mvaVec;
149 auto mergedMVA = *mergedMVAStore;
152 std::vector<std::array<int, 3>>
matches;
153 for (
int i = 0;
i < (
int)merged.size(); ++
i) {
154 auto cInd = candIndices[
i];
158 if (mergedMVA[
i] < -0.7
f)
163 if (dHits > diffHitsCut_)
169 if (matches.size() > 1)
170 for (
auto matchIter0 = matches.begin(); matchIter0 != matches.end() - 1; ++matchIter0) {
171 if ((*matchIter0)[0] < 0)
173 auto nchi2 = merged[(*matchIter0)[0]].normalizedChi2();
174 for (
auto matchIter1 = matchIter0 + 1; matchIter1 != matches.end(); ++matchIter1) {
175 if ((*matchIter1)[0] < 0)
177 if ((*matchIter0)[1] == (*matchIter1)[1] || (*matchIter0)[1] == (*matchIter1)[2] ||
178 (*matchIter0)[2] == (*matchIter1)[1] || (*matchIter0)[2] == (*matchIter1)[2]) {
179 auto nchi2_1 = merged[(*matchIter1)[0]].normalizedChi2();
180 if (nchi2_1 < nchi2) {
181 (*matchIter0)[0] = -1;
184 (*matchIter1)[0] = -1;
191 auto pmvas = std::make_unique<MVACollection>();
192 auto pquals = std::make_unique<QualityMaskCollection>();
197 std::vector<unsigned int> selId;
198 auto ntotTk = matches.size();
204 for (
auto matchIter0 = matches.begin(); matchIter0 != matches.end(); matchIter0++) {
205 if ((*matchIter0)[0] < 0)
207 selId.push_back((*matchIter0)[0]);
209 pmvas->push_back(mergedMVA[(*matchIter0)[0]]);
211 const reco::Track& inTrk1 = originals[(*matchIter0)[1]];
212 const reco::Track& inTrk2 = originals[(*matchIter0)[2]];
223 inputTracks.push_back((*matchIter0)[1]);
224 inputTracks.push_back((*matchIter0)[2]);
229 producer(mergedTrackSource_, selId);
230 assert(
producer.selTracks_->size() == pquals->size());
232 for (
auto isel = 0
U; isel < nsel; ++isel) {
234 auto& otk = (*
producer.selTracks_)[isel];
235 otk.setQualityMask((*pquals)[isel]);
237 otk.setOriginalAlgorithm(oriAlgo[isel]);
238 otk.setAlgoMask(algoMask[isel]);
242 for (
int i = 0;
i < (
int)originals.size();
i++) {
244 if (
std::find(inputTracks.begin(), inputTracks.end(),
i) != inputTracks.end())
247 pmvas->push_back((*originalMVAStore)[
i]);
251 producer(originalTrackSource_, selId);
252 assert(
producer.selTracks_->size() == pquals->size());
#define declareDynArray(T, n, x)
T getParameter(std::string const &) const
OrphanHandle< PROD > put(std::unique_ptr< PROD > product)
Put a new product.
bool getByToken(EDGetToken token, Handle< PROD > &result) const
size_t recHitsSize() const
Get number of RecHits. (Warning, this includes invalid hits, which are not physical hits)...
static void fill(edm::ParameterSetDescription &desc)
void find(edm::Handle< EcalRecHitCollection > &hits, DetId thisDet, std::vector< EcalRecHitCollection::const_iterator > &hit, bool debug=false)
TrackAlgorithm
track algorithm
TrackAlgorithm algo() const
#define DEFINE_FWK_MODULE(type)
ParameterDescriptionBase * add(U const &iLabel, T const &value)
std::bitset< algoSize > AlgoMask
algo mask
static void fillDescriptions(edm::ConfigurationDescriptions &descriptions)
AlgoMask algoMask() const
void add(std::string const &label, ParameterSetDescription const &psetDescription)
std::array< unsigned int, reco::TrackBase::algoSize > trackAlgoPriorityOrder