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);
106 descriptions.
add(
"DuplicateListMerger", desc);
110 collectionCloner(*this, iPara,
true),
111 mergedTrackSource_(iPara.getParameter<
edm::InputTag>(
"mergedSource"),consumesCollector()),
112 originalTrackSource_(iPara.getParameter<
edm::InputTag>(
"originalSource"),consumesCollector())
117 candidateComponents_ = consumes<CandidateToDuplicate>(iPara.getParameter<
edm::InputTag>(
"candidateComponents"));
119 mergedMVAValsToken_ = consumes<MVACollection>(iPara.getParameter<
edm::InputTag>(
"mergedMVAVals"));
120 originalMVAValsToken_ = consumes<MVACollection>(iPara.getParameter<
edm::InputTag>(
"originalMVAVals"));
124 produces<MVACollection>(
"MVAValues");
125 produces<QualityMaskCollection>(
"QualityMasks");
130 DuplicateListMerger::~DuplicateListMerger()
144 auto const & originals = originalTrackSource_.tracks(iEvent);
145 auto const & merged = mergedTrackSource_.tracks(iEvent);
146 auto const & candIndices = mergedTrackSource_.indicesInput(iEvent);
149 iEvent.
getByToken(candidateSource_,candidateH);
153 iEvent.
getByToken(candidateComponents_,candidateComponentsH);
161 iEvent.
getByToken(originalMVAValsToken_,originalMVAStore);
162 iEvent.
getByToken(mergedMVAValsToken_,mergedMVAStore);
164 MVACollection mvaVec;
167 auto mergedMVA = *mergedMVAStore;
170 std::vector<std::array<int,3>>
matches;
171 for(
int i = 0;
i < (
int)merged.size(); ++
i) {
172 auto cInd = candIndices[
i];
176 if (mergedMVA[
i]< -0.7
f)
continue;
180 if(dHits > diffHitsCut_)
continue;
185 if (matches.size()>1)
186 for (
auto matchIter0 = matches.begin(); matchIter0 != matches.end()-1; ++matchIter0) {
187 if ( (*matchIter0)[0]<0)
continue;
188 auto nchi2 = merged[(*matchIter0)[0]].normalizedChi2();
189 for(
auto matchIter1 = matchIter0+1; matchIter1 != matches.end(); ++matchIter1){
190 if ( (*matchIter1)[0]<0)
continue;
191 if ( (*matchIter0)[1]==(*matchIter1)[1]
192 || (*matchIter0)[1]==(*matchIter1)[2]
193 || (*matchIter0)[2]==(*matchIter1)[1]
194 || (*matchIter0)[2]==(*matchIter1)[2]
196 auto nchi2_1 = merged[(*matchIter1)[0]].normalizedChi2();
198 (*matchIter0)[0] = -1;
201 (*matchIter1)[0] = -1;
209 auto pmvas = std::make_unique<MVACollection>();
210 auto pquals = std::make_unique<QualityMaskCollection>();
217 std::vector<unsigned int> selId;
218 auto ntotTk = matches.size();
224 for(
auto matchIter0 = matches.begin(); matchIter0 != matches.end(); matchIter0++){
225 if ( (*matchIter0)[0]<0)
continue;
226 selId.push_back((*matchIter0)[0]);
228 pmvas->push_back(mergedMVA[(*matchIter0)[0]]);
230 const reco::Track& inTrk1 = originals[(*matchIter0)[1]];
231 const reco::Track& inTrk2 = originals[(*matchIter0)[2]];
243 inputTracks.push_back((*matchIter0)[1]);
244 inputTracks.push_back((*matchIter0)[2]);
253 assert(
producer.selTracks_->size()==pquals->size());
255 for (
auto isel=0
U;isel<nsel;++isel) {
257 auto & otk = (*
producer.selTracks_)[isel];
258 otk.setQualityMask((*pquals)[isel]);
260 otk.setOriginalAlgorithm(oriAlgo[isel]);
261 otk.setAlgoMask(algoMask[isel]);
266 for(
int i = 0;
i < (
int)originals.size();
i++){
268 if (
std::find(inputTracks.begin(),inputTracks.end(),
i) != inputTracks.end())
continue;
270 pmvas->push_back((*originalMVAStore)[
i]);
274 producer(originalTrackSource_,selId);
275 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)
#define declareDynArray(T, n, x)