50 using CandidateToDuplicate = std::vector<std::pair<int, int>>;
54 using MVACollection = std::vector<float>;
55 using QualityMaskCollection = std::vector<unsigned char>;
109 desc.
add<
std::string>(
"trackAlgoPriorityOrder",
"trackAlgoPriorityOrder");
110 desc.
add<
int>(
"diffHitsCut",5);
112 descriptions.
add(
"DuplicateListMerger", desc);
116 collectionCloner(*this, iPara,
true),
117 mergedTrackSource_(iPara.getParameter<
edm::InputTag>(
"mergedSource"),consumesCollector()),
118 originalTrackSource_(iPara.getParameter<
edm::InputTag>(
"originalSource"),consumesCollector()),
119 priorityName_(iPara.getParameter<
std::
string>(
"trackAlgoPriorityOrder"))
124 candidateComponents_ = consumes<CandidateToDuplicate>(iPara.getParameter<
edm::InputTag>(
"candidateComponents"));
126 mergedMVAValsToken_ = consumes<MVACollection>(iPara.getParameter<
edm::InputTag>(
"mergedMVAVals"));
127 originalMVAValsToken_ = consumes<MVACollection>(iPara.getParameter<
edm::InputTag>(
"originalMVAVals"));
131 produces<MVACollection>(
"MVAValues");
132 produces<QualityMaskCollection>(
"QualityMasks");
137 DuplicateListMerger::~DuplicateListMerger()
151 auto const & originals = originalTrackSource_.tracks(iEvent);
152 auto const & merged = mergedTrackSource_.tracks(iEvent);
153 auto const & candIndices = mergedTrackSource_.indicesInput(iEvent);
156 iEvent.
getByToken(candidateSource_,candidateH);
160 iEvent.
getByToken(candidateComponents_,candidateComponentsH);
168 iEvent.
getByToken(originalMVAValsToken_,originalMVAStore);
169 iEvent.
getByToken(mergedMVAValsToken_,mergedMVAStore);
175 MVACollection mvaVec;
178 auto mergedMVA = *mergedMVAStore;
181 std::vector<std::array<int,3>>
matches;
182 for(
int i = 0;
i < (
int)merged.size(); ++
i) {
183 auto cInd = candIndices[
i];
187 if (mergedMVA[
i]< -0.7
f)
continue;
191 if(dHits > diffHitsCut_)
continue;
196 if (matches.size()>1)
197 for (
auto matchIter0 = matches.begin(); matchIter0 != matches.end()-1; ++matchIter0) {
198 if ( (*matchIter0)[0]<0)
continue;
199 auto nchi2 = merged[(*matchIter0)[0]].normalizedChi2();
200 for(
auto matchIter1 = matchIter0+1; matchIter1 != matches.end(); ++matchIter1){
201 if ( (*matchIter1)[0]<0)
continue;
202 if ( (*matchIter0)[1]==(*matchIter1)[1]
203 || (*matchIter0)[1]==(*matchIter1)[2]
204 || (*matchIter0)[2]==(*matchIter1)[1]
205 || (*matchIter0)[2]==(*matchIter1)[2]
207 auto nchi2_1 = merged[(*matchIter1)[0]].normalizedChi2();
209 (*matchIter0)[0] = -1;
212 (*matchIter1)[0] = -1;
220 auto pmvas = std::make_unique<MVACollection>();
221 auto pquals = std::make_unique<QualityMaskCollection>();
228 std::vector<unsigned int> selId;
229 auto ntotTk = matches.size();
235 for(
auto matchIter0 = matches.begin(); matchIter0 != matches.end(); matchIter0++){
236 if ( (*matchIter0)[0]<0)
continue;
237 selId.push_back((*matchIter0)[0]);
239 pmvas->push_back(mergedMVA[(*matchIter0)[0]]);
241 const reco::Track& inTrk1 = originals[(*matchIter0)[1]];
242 const reco::Track& inTrk2 = originals[(*matchIter0)[2]];
254 inputTracks.push_back((*matchIter0)[1]);
255 inputTracks.push_back((*matchIter0)[2]);
264 assert(
producer.selTracks_->size()==pquals->size());
266 for (
auto isel=0
U;isel<nsel;++isel) {
268 auto & otk = (*
producer.selTracks_)[isel];
269 otk.setQualityMask((*pquals)[isel]);
271 otk.setOriginalAlgorithm(oriAlgo[isel]);
272 otk.setAlgoMask(algoMask[isel]);
277 for(
int i = 0;
i < (
int)originals.size();
i++){
279 if (
std::find(inputTracks.begin(),inputTracks.end(),
i) != inputTracks.end())
continue;
281 pmvas->push_back((*originalMVAStore)[
i]);
285 producer(originalTrackSource_,selId);
286 assert(
producer.selTracks_->size()==pquals->size());
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
#define DEFINE_FWK_MODULE(type)
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
ParameterDescriptionBase * add(U const &iLabel, T const &value)
static void fillDescriptions(ConfigurationDescriptions &descriptions)
std::bitset< algoSize > AlgoMask
algo mask
AlgoMask algoMask() const
void add(std::string const &label, ParameterSetDescription const &psetDescription)
std::array< unsigned int, reco::TrackBase::algoSize > trackAlgoPriorityOrder
#define declareDynArray(T, n, x)