47 using CandidateToDuplicate = std::vector<std::pair<int, int>>;
51 using MVACollection = std::vector<float>;
52 using QualityMaskCollection = std::vector<unsigned char>;
104 desc.
add<
int>(
"diffHitsCut",5);
105 descriptions.
add(
"DuplicateListMerger", desc);
109 collectionCloner(*this, iPara,
true),
110 mergedTrackSource_(iPara.getParameter<edm::
InputTag>(
"mergedSource"),consumesCollector()),
111 originalTrackSource_(iPara.getParameter<edm::
InputTag>(
"originalSource"),consumesCollector())
116 candidateComponents_ = consumes<CandidateToDuplicate>(iPara.getParameter<
edm::InputTag>(
"candidateComponents"));
118 mergedMVAValsToken_ = consumes<MVACollection>(iPara.getParameter<
edm::InputTag>(
"mergedMVAVals"));
119 originalMVAValsToken_ = consumes<MVACollection>(iPara.getParameter<
edm::InputTag>(
"originalMVAVals"));
123 produces<MVACollection>(
"MVAValues");
124 produces<QualityMaskCollection>(
"QualityMasks");
129 DuplicateListMerger::~DuplicateListMerger()
143 auto const & originals = originalTrackSource_.tracks(iEvent);
144 auto const & merged = mergedTrackSource_.tracks(iEvent);
145 auto const & candIndices = mergedTrackSource_.indicesInput(iEvent);
148 iEvent.
getByToken(candidateSource_,candidateH);
152 iEvent.
getByToken(candidateComponents_,candidateComponentsH);
153 auto const & candidateComponents = *candidateComponentsH;
160 iEvent.
getByToken(originalMVAValsToken_,originalMVAStore);
161 iEvent.
getByToken(mergedMVAValsToken_,mergedMVAStore);
163 MVACollection mvaVec;
166 auto mergedMVA = *mergedMVAStore;
169 std::vector<std::array<int,3>>
matches;
170 for(
int i = 0;
i < (int)merged.size(); ++
i) {
171 auto cInd = candIndices[
i];
175 if (mergedMVA[
i]< -0.7
f)
continue;
178 int dHits = (cand.recHits().second - cand.recHits().first) - matchedTrack.
recHitsSize();
179 if(dHits > diffHitsCut_)
continue;
180 matches.push_back(std::array<int,3>{{
i,candidateComponents[cInd].first,candidateComponents[cInd].second}});
184 if (matches.size()>1)
185 for (
auto matchIter0 = matches.begin(); matchIter0 != matches.end()-1; ++matchIter0) {
186 if ( (*matchIter0)[0]<0)
continue;
187 auto nchi2 = merged[(*matchIter0)[0]].normalizedChi2();
188 for(
auto matchIter1 = matchIter0+1; matchIter1 != matches.end(); ++matchIter1){
189 if ( (*matchIter1)[0]<0)
continue;
190 if ( (*matchIter0)[1]==(*matchIter1)[1]
191 || (*matchIter0)[1]==(*matchIter1)[2]
192 || (*matchIter0)[2]==(*matchIter1)[1]
193 || (*matchIter0)[2]==(*matchIter1)[2]
195 auto nchi2_1 = merged[(*matchIter1)[0]].normalizedChi2();
197 (*matchIter0)[0] = -1;
200 (*matchIter1)[0] = -1;
208 auto pmvas = std::make_unique<MVACollection>();
209 auto pquals = std::make_unique<QualityMaskCollection>();
213 std::vector<int> inputTracks;
216 std::vector<unsigned int> selId;
217 auto ntotTk = matches.size();
223 for(
auto matchIter0 = matches.begin(); matchIter0 != matches.end(); matchIter0++){
224 if ( (*matchIter0)[0]<0)
continue;
225 selId.push_back((*matchIter0)[0]);
227 pmvas->push_back(mergedMVA[(*matchIter0)[0]]);
229 const reco::Track& inTrk1 = originals[(*matchIter0)[1]];
230 const reco::Track& inTrk2 = originals[(*matchIter0)[2]];
242 inputTracks.push_back((*matchIter0)[1]);
243 inputTracks.push_back((*matchIter0)[2]);
254 for (
auto isel=0U;isel<nsel;++isel) {
256 auto & otk = (*
producer.selTracks_)[isel];
257 otk.setQualityMask((*pquals)[isel]);
259 otk.setOriginalAlgorithm(oriAlgo[isel]);
260 otk.setAlgoMask(algoMask[isel]);
265 for(
int i = 0;
i < (int)originals.size();
i++){
267 if (
std::find(inputTracks.begin(),inputTracks.end(),
i) != inputTracks.end())
continue;
269 pmvas->push_back((*originalMVAStore)[
i]);
273 producer(originalTrackSource_,selId);
T getParameter(std::string const &) const
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)...
void find(edm::Handle< EcalRecHitCollection > &hits, DetId thisDet, std::vector< EcalRecHitCollection::const_iterator > &hit, bool debug=false)
TrackAlgorithm
track algorithm
TrackAlgorithm algo() const
OrphanHandle< PROD > put(std::auto_ptr< PROD > product)
Put a new product.
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)
#define declareDynArray(T, n, x)