CMS 3D CMS Logo

List of all members | Public Member Functions | Private Member Functions | Private Attributes
trklet::PurgeDuplicate Class Reference

#include <PurgeDuplicate.h>

Inheritance diagram for trklet::PurgeDuplicate:
trklet::ProcessBase

Public Member Functions

void addInput (MemoryBase *memory, std::string input) override
 
void addOutput (MemoryBase *memory, std::string output) override
 
void execute (std::vector< Track > &outputtracks, unsigned int iSector)
 
 PurgeDuplicate (std::string name, Settings const &settings, Globals *global)
 
 ~PurgeDuplicate () override=default
 
- Public Member Functions inherited from trklet::ProcessBase
unsigned int getISeed (const std::string &name)
 
std::string const & getName () const
 
void initLayerDisk (unsigned int pos, int &layer, int &disk)
 
void initLayerDisk (unsigned int pos, int &layer, int &disk, int &layerdisk)
 
unsigned int initLayerDisk (unsigned int pos)
 
void initLayerDisksandISeed (unsigned int &layerdisk1, unsigned int &layerdisk2, unsigned int &iSeed)
 
unsigned int nbits (unsigned int power)
 
 ProcessBase (std::string name, Settings const &settings, Globals *global)
 
virtual ~ProcessBase ()=default
 

Private Member Functions

std::pair< int, int > findLayerDisk (const Stub *) const
 
std::vector< unsigned int > findOverlapPhiBins (const Tracklet *trk) const
 
std::vector< unsigned int > findOverlapRinvBins (const Tracklet *trk) const
 
unsigned int findPhiBin (const Tracklet *trk) const
 
unsigned int findRinvBin (const Tracklet *trk) const
 
std::vector< double > getInventedCoords (unsigned int, const Stub *, const Tracklet *) const
 
std::vector< double > getInventedCoordsExtended (unsigned int, const Stub *, const Tracklet *) const
 
std::vector< const Stub * > getInventedSeedingStub (unsigned int, const Tracklet *, const std::vector< const Stub *> &) const
 
double getPhiRes (Tracklet *curTracklet, const Stub *curStub) const
 
bool isSeedingStub (int, int, int) const
 
bool isTrackInBin (const std::vector< unsigned int > &vec, unsigned int num) const
 
std::string l1tinfo (const L1TStub *, std::string) const
 

Private Attributes

std::vector< std::vector< std::pair< int, int > > > inputstubidslists_
 
std::vector< std::vector< const Stub * > > inputstublists_
 
std::vector< TrackFitMemory * > inputtrackfits_
 
std::vector< Tracklet * > inputtracklets_
 
std::vector< Track * > inputtracks_
 
std::vector< std::vector< std::pair< int, int > > > mergedstubidslists_
 
std::vector< CleanTrackMemory * > outputtracklets_
 

Additional Inherited Members

- Protected Attributes inherited from trklet::ProcessBase
Globalsglobals_
 
std::string name_
 
Settings const & settings_
 

Detailed Description

Definition at line 27 of file PurgeDuplicate.h.

Constructor & Destructor Documentation

◆ PurgeDuplicate()

PurgeDuplicate::PurgeDuplicate ( std::string  name,
Settings const &  settings,
Globals global 
)

Definition at line 27 of file PurgeDuplicate.cc.

28  : ProcessBase(name, settings, global) {}
ProcessBase(std::string name, Settings const &settings, Globals *global)
Definition: ProcessBase.cc:14

◆ ~PurgeDuplicate()

trklet::PurgeDuplicate::~PurgeDuplicate ( )
overridedefault

Member Function Documentation

◆ addInput()

void PurgeDuplicate::addInput ( MemoryBase memory,
std::string  input 
)
overridevirtual

Implements trklet::ProcessBase.

Definition at line 56 of file PurgeDuplicate.cc.

References cms::cuda::assert(), Exception, input, PixelMapPlotter::inputs, inputtrackfits_, mps_setup::memory, trklet::ProcessBase::name_, trklet::ProcessBase::settings_, createJobs::tmp, and trklet::Settings::writetrace().

56  {
57  if (settings_.writetrace()) {
58  edm::LogVerbatim("Tracklet") << "In " << name_ << " adding input from " << memory->getName() << " to input "
59  << input;
60  }
61  unordered_set<string> inputs = {"trackin",
62  "trackin1",
63  "trackin2",
64  "trackin3",
65  "trackin4",
66  "trackin5",
67  "trackin6",
68  "trackin7",
69  "trackin8",
70  "trackin9",
71  "trackin10",
72  "trackin11",
73  "trackin12"};
74  if (inputs.find(input) != inputs.end()) {
75  auto* tmp = dynamic_cast<TrackFitMemory*>(memory);
76  assert(tmp != nullptr);
77  inputtrackfits_.push_back(tmp);
78  return;
79  }
80  throw cms::Exception("BadConfig") << __FILE__ << " " << __LINE__ << " could not find input: " << input;
81 }
Log< level::Info, true > LogVerbatim
std::string name_
Definition: ProcessBase.h:38
Settings const & settings_
Definition: ProcessBase.h:40
bool writetrace() const
Definition: Settings.h:195
assert(be >=bs)
static std::string const input
Definition: EdmProvDump.cc:50
std::vector< TrackFitMemory * > inputtrackfits_
tmp
align.sh
Definition: createJobs.py:716

◆ addOutput()

void PurgeDuplicate::addOutput ( MemoryBase memory,
std::string  output 
)
overridevirtual

Implements trklet::ProcessBase.

Definition at line 30 of file PurgeDuplicate.cc.

References cms::cuda::assert(), Exception, mps_setup::memory, trklet::ProcessBase::name_, convertSQLitetoXML_cfg::output, PatBasicFWLiteJetAnalyzer_Selector_cfg::outputs, outputtracklets_, trklet::ProcessBase::settings_, createJobs::tmp, and trklet::Settings::writetrace().

30  {
31  if (settings_.writetrace()) {
32  edm::LogVerbatim("Tracklet") << "In " << name_ << " adding output to " << memory->getName() << " to output "
33  << output;
34  }
35  unordered_set<string> outputs = {"trackout",
36  "trackout1",
37  "trackout2",
38  "trackout3",
39  "trackout4",
40  "trackout5",
41  "trackout6",
42  "trackout7",
43  "trackout8",
44  "trackout9",
45  "trackout10",
46  "trackout11"};
47  if (outputs.find(output) != outputs.end()) {
48  auto* tmp = dynamic_cast<CleanTrackMemory*>(memory);
49  assert(tmp != nullptr);
50  outputtracklets_.push_back(tmp);
51  return;
52  }
53  throw cms::Exception("BadConfig") << __FILE__ << " " << __LINE__ << " could not find output: " << output;
54 }
Log< level::Info, true > LogVerbatim
std::string name_
Definition: ProcessBase.h:38
Settings const & settings_
Definition: ProcessBase.h:40
bool writetrace() const
Definition: Settings.h:195
std::vector< CleanTrackMemory * > outputtracklets_
assert(be >=bs)
Definition: output.py:1
tmp
align.sh
Definition: createJobs.py:716

◆ execute()

void PurgeDuplicate::execute ( std::vector< Track > &  outputtracks,
unsigned int  iSector 
)

Definition at line 83 of file PurgeDuplicate.cc.

References Reference_intrackfit_cff::barrel, newFWLiteAna::bin, Exception, trklet::Settings::extended(), spr::find(), findOverlapPhiBins(), findOverlapRinvBins(), findPhiBin(), findRinvBin(), dqmdumpme::first, trklet::HybridFit::Fit(), trklet::Tracklet::fit(), groupFilesInBlocks::fout, getInventedSeedingStub(), getPhiRes(), getTrack(), trklet::Tracklet::getTrack(), trklet::ProcessBase::globals_, getRunAppsInfo::grid, mps_fire::i, trklet::Track::ichisq(), inputstubidslists_, inputstublists_, inputtrackfits_, inputtracklets_, inputtracks_, createfilelist::int, trklet::Settings::inventStubs(), isTrackInBin(), dqmiolumiharvest::j, M_PI, SiStripPI::max, trklet::Settings::maxStep(), trklet::Settings::mergeComparison(), mergedstubidslists_, SiStripPI::min, trklet::Settings::minIndStubs(), trklet::ProcessBase::name_, trklet::Settings::numTracksComparedPerBin(), outputtracklets_, BeamMonitor_cff::phiBin, trklet::Settings::phiBins(), muonRecoAnalyzer_cfi::ptBin, trklet::Settings::removalType(), trklet::Settings::rinvBins(), edm::second(), trklet::Tracklet::seedIndex(), trklet::Track::setSector(), trklet::Track::setStubIDprefit(), trklet::Track::setStubIDpremerge(), trklet::ProcessBase::settings_, jetUpdater_cfi::sort, trklet::Track::stubID(), ecalIM::uniqueIndex(), and trklet::Settings::writeMonitorData().

83  {
84  inputtracklets_.clear();
85  inputtracks_.clear();
86 
87  inputstubidslists_.clear();
88  inputstublists_.clear();
89  mergedstubidslists_.clear();
90 
91  if (settings_.removalType() != "merge") {
92  for (auto& inputtrackfit : inputtrackfits_) {
93  if (inputtrackfit->nTracks() == 0)
94  continue;
95  for (unsigned int j = 0; j < inputtrackfit->nTracks(); j++) {
96  Track* aTrack = inputtrackfit->getTrack(j)->getTrack();
97  aTrack->setSector(iSector);
98  inputtracks_.push_back(aTrack);
99  }
100  }
101  if (inputtracks_.empty())
102  return;
103  }
104 
105  unsigned int numTrk = inputtracks_.size();
106 
108  // Hybrid Removal //
110 #ifdef USEHYBRID
111 
112  if (settings_.removalType() == "merge") {
113  // Track seed & duplicate flag
114  std::vector<std::pair<int, bool>> trackInfo;
115  // Flag for tracks in multiple bins that get merged but are not in the correct bin
116  std::vector<bool> trackBinInfo;
117  // Vector to store the relative rank of the track candidate for merging, based on seed type
118  std::vector<int> seedRank;
119 
120  // Stubs on every track
121  std::vector<std::vector<const Stub*>> inputstublistsall;
122  // (layer, unique stub index within layer) of each stub on every track
123  std::vector<std::vector<std::pair<int, int>>> mergedstubidslistsall;
124  std::vector<std::vector<std::pair<int, int>>> inputstubidslistsall;
125  std::vector<Tracklet*> inputtrackletsall;
126 
127  std::vector<unsigned int> prefTracks; // Stores all the tracks that are sent to the KF from each bin
128  std::vector<int> prefTrackFit; // Stores the track seed that corresponds to the associated track in prefTracks
129 
130  for (unsigned int bin = 0; bin < settings_.rinvBins().size() - 1; bin++) {
131  for (unsigned int phiBin = 0; phiBin < settings_.phiBins().size() - 1; phiBin++) {
132  // Get vectors from TrackFit and save them
133  // inputtracklets: Tracklet objects from the FitTrack (not actually fit yet)
134  // inputstublists: L1Stubs for that track
135  // inputstubidslists: Stub stubIDs for that 3rack
136  // mergedstubidslists: the same as inputstubidslists, but will be used during duplicate removal
137  for (unsigned int i = 0; i < inputtrackfits_.size(); i++) {
138  if (inputtrackfits_[i]->nStublists() == 0)
139  continue;
140  if (inputtrackfits_[i]->nStublists() != inputtrackfits_[i]->nTracks())
141  throw cms::Exception("LogicError")
142  << __FILE__ << " " << __LINE__ << " Number of stublists and tracks don't match up! ";
143  for (unsigned int j = 0; j < inputtrackfits_[i]->nStublists(); j++) {
146  continue;
147  if (inputtracklets_.size() >= settings_.maxStep("DR"))
148  continue;
149  Tracklet* aTrack = inputtrackfits_[i]->getTrack(j);
151  std::vector<const Stub*> stublist = inputtrackfits_[i]->getStublist(j);
152  inputstublists_.push_back(stublist);
153  std::vector<std::pair<int, int>> stubidslist = inputtrackfits_[i]->getStubidslist(j);
154  inputstubidslists_.push_back(stubidslist);
155  mergedstubidslists_.push_back(stubidslist);
156 
157  // Encoding: L1L2=0, L2L3=1, L3L4=2, L5L6=3, D1D2=4, D3D4=5, L1D1=6, L2D1=7
158  // Best Guess: L1L2 > L1D1 > L2L3 > L2D1 > D1D2 > L3L4 > L5L6 > D3D4
159  // Best Rank: L1L2 > L3L4 > D3D4 > D1D2 > L2L3 > L2D1 > L5L6 > L1D1
160  // Rank-Informed Guess: L1L2 > L3L4 > L1D1 > L2L3 > L2D1 > D1D2 > L5L6 > D3D4
161  const unsigned int curSeed = aTrack->seedIndex();
162  static const std::vector<int> ranks{1, 5, 2, 7, 4, 3, 8, 6};
163  if (curSeed < ranks.size()) {
164  seedRank.push_back(ranks[curSeed]);
165  } else if (settings_.extended()) {
166  seedRank.push_back(9);
167  } else {
168  throw cms::Exception("LogError") << __FILE__ << " " << __LINE__ << " Seed type " << curSeed
169  << " not found in list, and settings->extended() not set.";
170  }
171 
172  if (stublist.size() != stubidslist.size())
173  throw cms::Exception("LogicError")
174  << __FILE__ << " " << __LINE__ << " Number of stubs and stubids don't match up! ";
175 
176  trackInfo.emplace_back(i, false);
177  trackBinInfo.emplace_back(false);
178  } else
179  continue;
180  }
181  }
182 
183  if (inputtracklets_.empty())
184  continue;
185  const unsigned int numStublists = inputstublists_.size();
186 
187  if (settings_.inventStubs()) {
188  for (unsigned int itrk = 0; itrk < numStublists; itrk++) {
190  }
191  }
192 
193  // Initialize all-false 2D array of tracks being duplicates to other tracks
194  bool dupMap[numStublists][numStublists]; // Ends up symmetric
195  for (unsigned int itrk = 0; itrk < numStublists; itrk++) {
196  for (unsigned int jtrk = 0; jtrk < numStublists; jtrk++) {
197  dupMap[itrk][jtrk] = false;
198  }
199  }
200 
201  // Used to check if a track is in two bins, is not a duplicate in either bin, so is sent out twice
202  bool noMerge[numStublists];
203  for (unsigned int itrk = 0; itrk < numStublists; itrk++) {
204  noMerge[itrk] = false;
205  }
206 
207  // Find duplicates; Fill dupMap by looping over all pairs of "tracks"
208  // numStublists-1 since last track has no other to compare to
209  for (unsigned int itrk = 0; itrk < numStublists - 1; itrk++) {
210  for (unsigned int jtrk = itrk + 1; jtrk < numStublists; jtrk++) {
211  if (itrk >= settings_.numTracksComparedPerBin())
212  continue;
213  // Get primary track stubids = (layer, unique stub index within layer)
214  const std::vector<std::pair<int, int>>& stubsTrk1 = inputstubidslists_[itrk];
215 
216  // Get and count secondary track stubids
217  const std::vector<std::pair<int, int>>& stubsTrk2 = inputstubidslists_[jtrk];
218 
219  // Count number of layers that share stubs, and the number of UR that each track hits
220  unsigned int nShareLay = 0;
221  if (settings_.mergeComparison() == "CompareAll") {
222  bool layerArr[16];
223  for (auto& i : layerArr) {
224  i = false;
225  };
226  for (const auto& st1 : stubsTrk1) {
227  for (const auto& st2 : stubsTrk2) {
228  if (st1.first == st2.first && st1.second == st2.second) { // tracks share stub
229  // Converts layer/disk encoded in st1->first to an index in the layer array
230  int i = st1.first; // layer/disk
231  bool barrel = (i > 0 && i < 10);
232  bool endcapA = (i > 10);
233  bool endcapB = (i < 0);
234  int lay = barrel * (i - 1) + endcapA * (i - 5) - endcapB * i; // encode in range 0-15
235  if (!layerArr[lay]) {
236  nShareLay++;
237  layerArr[lay] = true;
238  }
239  }
240  }
241  }
242  } else if (settings_.mergeComparison() == "CompareBest") {
243  std::vector<const Stub*> fullStubslistsTrk1 = inputstublists_[itrk];
244  std::vector<const Stub*> fullStubslistsTrk2 = inputstublists_[jtrk];
245 
246  // Arrays to store the index of the best stub in each layer
247  int layStubidsTrk1[16];
248  int layStubidsTrk2[16];
249  for (int i = 0; i < 16; i++) {
250  layStubidsTrk1[i] = -1;
251  layStubidsTrk2[i] = -1;
252  }
253  // For each stub on the first track, find the stub with the best residual and store its index in the layStubidsTrk1 array
254  for (unsigned int stcount = 0; stcount < stubsTrk1.size(); stcount++) {
255  int i = stubsTrk1[stcount].first; // layer/disk
256  bool barrel = (i > 0 && i < 10);
257  bool endcapA = (i > 10);
258  bool endcapB = (i < 0);
259  int lay = barrel * (i - 1) + endcapA * (i - 5) - endcapB * i; // encode in range 0-15
260  double nres = getPhiRes(inputtracklets_[itrk], fullStubslistsTrk1[stcount]);
261  double ores = 0;
262  if (layStubidsTrk1[lay] != -1)
263  ores = getPhiRes(inputtracklets_[itrk], fullStubslistsTrk1[layStubidsTrk1[lay]]);
264  if (layStubidsTrk1[lay] == -1 || nres < ores) {
265  layStubidsTrk1[lay] = stcount;
266  }
267  }
268  // For each stub on the second track, find the stub with the best residual and store its index in the layStubidsTrk1 array
269  for (unsigned int stcount = 0; stcount < stubsTrk2.size(); stcount++) {
270  int i = stubsTrk2[stcount].first; // layer/disk
271  bool barrel = (i > 0 && i < 10);
272  bool endcapA = (i > 10);
273  bool endcapB = (i < 0);
274  int lay = barrel * (i - 1) + endcapA * (i - 5) - endcapB * i; // encode in range 0-15
275  double nres = getPhiRes(inputtracklets_[jtrk], fullStubslistsTrk2[stcount]);
276  double ores = 0;
277  if (layStubidsTrk2[lay] != -1)
278  ores = getPhiRes(inputtracklets_[jtrk], fullStubslistsTrk2[layStubidsTrk2[lay]]);
279  if (layStubidsTrk2[lay] == -1 || nres < ores) {
280  layStubidsTrk2[lay] = stcount;
281  }
282  }
283  // For all 16 layers (6 layers and 10 disks), count the number of layers who's best stub on both tracks are the same
284  for (int i = 0; i < 16; i++) {
285  int t1i = layStubidsTrk1[i];
286  int t2i = layStubidsTrk2[i];
287  if (t1i != -1 && t2i != -1 && stubsTrk1[t1i].first == stubsTrk2[t2i].first &&
288  stubsTrk1[t1i].second == stubsTrk2[t2i].second)
289  nShareLay++;
290  }
291  }
292 
293  // Fill duplicate map
294  if (nShareLay >= settings_.minIndStubs()) { // For number of shared stub merge condition
295  dupMap[itrk][jtrk] = true;
296  dupMap[jtrk][itrk] = true;
297  }
298  }
299  }
300 
301  // Check to see if the track is a duplicate
302  for (unsigned int itrk = 0; itrk < numStublists; itrk++) {
303  for (unsigned int jtrk = 0; jtrk < numStublists; jtrk++) {
304  if (dupMap[itrk][jtrk]) {
305  noMerge[itrk] = true;
306  }
307  }
308  }
309 
310  // If the track isn't a duplicate, and if it's in more than one bin, and it is not in the proper rinv or phi bin, then mark it so it won't be sent to output
311  for (unsigned int itrk = 0; itrk < numStublists; itrk++) {
312  if (noMerge[itrk] == false) {
313  if (((findOverlapRinvBins(inputtracklets_[itrk]).size() > 1) &&
314  (findRinvBin(inputtracklets_[itrk]) != bin)) ||
315  ((findOverlapPhiBins(inputtracklets_[itrk]).size() > 1) &&
316  findPhiBin(inputtracklets_[itrk]) != phiBin)) {
317  trackInfo[itrk].second = true;
318  }
319  }
320  }
321  // Merge duplicate tracks
322  for (unsigned int itrk = 0; itrk < numStublists - 1; itrk++) {
323  for (unsigned int jtrk = itrk + 1; jtrk < numStublists; jtrk++) {
324  // Merge a track with its first duplicate found.
325  if (dupMap[itrk][jtrk]) {
326  // Set preferred track based on seed rank
327  int preftrk;
328  int rejetrk;
329  if (seedRank[itrk] < seedRank[jtrk]) {
330  preftrk = itrk;
331  rejetrk = jtrk;
332  } else {
333  preftrk = jtrk;
334  rejetrk = itrk;
335  }
336 
337  // If the preffered track is in more than one bin, but not in the proper rinv or phi bin, then mark as true
338  if (((findOverlapRinvBins(inputtracklets_[preftrk]).size() > 1) &&
339  (findRinvBin(inputtracklets_[preftrk]) != bin)) ||
340  ((findOverlapPhiBins(inputtracklets_[preftrk]).size() > 1) &&
341  (findPhiBin(inputtracklets_[preftrk]) != phiBin))) {
342  trackBinInfo[preftrk] = true;
343  trackBinInfo[rejetrk] = true;
344  } else {
345  // Get a merged stub list
346  std::vector<const Stub*> newStubList;
347  std::vector<const Stub*> stubsTrk1 = inputstublists_[preftrk];
348  std::vector<const Stub*> stubsTrk2 = inputstublists_[rejetrk];
349  std::vector<unsigned int> stubsTrk1indices;
350  std::vector<unsigned int> stubsTrk2indices;
351  for (unsigned int stub1it = 0; stub1it < stubsTrk1.size(); stub1it++) {
352  stubsTrk1indices.push_back(stubsTrk1[stub1it]->l1tstub()->uniqueIndex());
353  }
354  for (unsigned int stub2it = 0; stub2it < stubsTrk2.size(); stub2it++) {
355  stubsTrk2indices.push_back(stubsTrk2[stub2it]->l1tstub()->uniqueIndex());
356  }
357  newStubList = stubsTrk1;
358  for (unsigned int stub2it = 0; stub2it < stubsTrk2.size(); stub2it++) {
359  if (find(stubsTrk1indices.begin(), stubsTrk1indices.end(), stubsTrk2indices[stub2it]) ==
360  stubsTrk1indices.end()) {
361  newStubList.push_back(stubsTrk2[stub2it]);
362  }
363  }
364  // Overwrite stublist of preferred track with merged list
365  inputstublists_[preftrk] = newStubList;
366 
367  std::vector<std::pair<int, int>> newStubidsList;
368  std::vector<std::pair<int, int>> stubidsTrk1 = mergedstubidslists_[preftrk];
369  std::vector<std::pair<int, int>> stubidsTrk2 = mergedstubidslists_[rejetrk];
370  newStubidsList = stubidsTrk1;
371 
372  for (unsigned int stub2it = 0; stub2it < stubsTrk2.size(); stub2it++) {
373  if (find(stubsTrk1indices.begin(), stubsTrk1indices.end(), stubsTrk2indices[stub2it]) ==
374  stubsTrk1indices.end()) {
375  newStubidsList.push_back(stubidsTrk2[stub2it]);
376  }
377  }
378  // Overwrite stubidslist of preferred track with merged list
379  mergedstubidslists_[preftrk] = newStubidsList;
380 
381  // Mark that rejected track has been merged into another track
382  trackInfo[rejetrk].second = true;
383  }
384  }
385  }
386  }
387 
388  for (unsigned int ktrk = 0; ktrk < numStublists; ktrk++) {
389  if ((trackInfo[ktrk].second != true) && (trackBinInfo[ktrk] != true)) {
390  prefTracks.push_back(ktrk);
391  prefTrackFit.push_back(trackInfo[ktrk].first);
392  inputtrackletsall.push_back(inputtracklets_[ktrk]);
393  inputstublistsall.push_back(inputstublists_[ktrk]);
394  inputstubidslistsall.push_back(inputstubidslists_[ktrk]);
395  mergedstubidslistsall.push_back(mergedstubidslists_[ktrk]);
396  }
397  }
398 
399  // Need to clear all the vectors which will be used in the next bin
400  seedRank.clear();
401  trackInfo.clear();
402  trackBinInfo.clear();
403  inputtracklets_.clear();
404  inputstublists_.clear();
405  inputstubidslists_.clear();
406  mergedstubidslists_.clear();
407  }
408  }
409 
410  // Make the final track objects, fit with KF, and send to output
411  for (unsigned int itrk = 0; itrk < prefTracks.size(); itrk++) {
412  Tracklet* tracklet = inputtrackletsall[itrk];
413  std::vector<const Stub*> trackstublist = inputstublistsall[itrk];
414 
415  // Run KF track fit
416  HybridFit hybridFitter(iSector, settings_, globals_);
417  hybridFitter.Fit(tracklet, trackstublist);
418 
419  // If the track was accepted (and thus fit), add to output
420  if (tracklet->fit()) {
421  // Add fitted Track to output (later converted to TTTrack)
422  Track* outtrack = tracklet->getTrack();
423  outtrack->setSector(iSector);
424  // Also store fitted track as more detailed Tracklet object.
425  outputtracklets_[prefTrackFit[itrk]]->addTrack(tracklet);
426 
427  // Add all tracks to standalone root file output
428  outtrack->setStubIDpremerge(inputstubidslistsall[itrk]);
429  outtrack->setStubIDprefit(mergedstubidslistsall[itrk]);
430  outputtracks.push_back(*outtrack);
431  }
432  }
433  }
434 
435 #endif
436 
438  // Grid removal //
440  if (settings_.removalType() == "grid") {
441  // Sort tracks by ichisq/DoF so that removal will keep the lower ichisq/DoF track
442  std::sort(inputtracks_.begin(), inputtracks_.end(), [](const Track* lhs, const Track* rhs) {
443  return lhs->ichisq() / lhs->stubID().size() < rhs->ichisq() / rhs->stubID().size();
444  });
445  bool grid[35][40] = {{false}};
446 
447  for (unsigned int itrk = 0; itrk < numTrk; itrk++) {
448  if (inputtracks_[itrk]->duplicate())
449  edm::LogPrint("Tracklet") << "WARNING: Track already tagged as duplicate!!";
450 
451  double phiBin = (inputtracks_[itrk]->phi0(settings_) - 2 * M_PI / 27 * iSector) / (2 * M_PI / 9 / 50) + 9;
452  phiBin = std::max(phiBin, 0.);
453  phiBin = std::min(phiBin, 34.);
454 
455  double ptBin = 1 / inputtracks_[itrk]->pt(settings_) * 40 + 20;
456  ptBin = std::max(ptBin, 0.);
457  ptBin = std::min(ptBin, 39.);
458 
459  if (grid[(int)phiBin][(int)ptBin])
460  inputtracks_[itrk]->setDuplicate(true);
461  grid[(int)phiBin][(int)ptBin] = true;
462 
463  double phiTest = inputtracks_[itrk]->phi0(settings_) - 2 * M_PI / 27 * iSector;
464  if (phiTest < -2 * M_PI / 27)
465  edm::LogVerbatim("Tracklet") << "track phi too small!";
466  if (phiTest > 2 * 2 * M_PI / 27)
467  edm::LogVerbatim("Tracklet") << "track phi too big!";
468  }
469  } // end grid removal
470 
472  // ichi + nstub removal //
474  if (settings_.removalType() == "ichi" || settings_.removalType() == "nstub") {
475  for (unsigned int itrk = 0; itrk < numTrk - 1; itrk++) { // numTrk-1 since last track has no other to compare to
476 
477  // If primary track is a duplicate, it cannot veto any...move on
478  if (inputtracks_[itrk]->duplicate() == 1)
479  continue;
480 
481  unsigned int nStubP = 0;
482  vector<unsigned int> nStubS(numTrk);
483  vector<unsigned int> nShare(numTrk);
484  // Get and count primary stubs
485  std::map<int, int> stubsTrk1 = inputtracks_[itrk]->stubID();
486  nStubP = stubsTrk1.size();
487 
488  for (unsigned int jtrk = itrk + 1; jtrk < numTrk; jtrk++) {
489  // Skip duplicate tracks
490  if (inputtracks_[jtrk]->duplicate() == 1)
491  continue;
492 
493  // Get and count secondary stubs
494  std::map<int, int> stubsTrk2 = inputtracks_[jtrk]->stubID();
495  nStubS[jtrk] = stubsTrk2.size();
496 
497  // Count shared stubs
498  for (auto& st : stubsTrk1) {
499  if (stubsTrk2.find(st.first) != stubsTrk2.end()) {
500  if (st.second == stubsTrk2[st.first])
501  nShare[jtrk]++;
502  }
503  }
504  }
505 
506  // Tag duplicates
507  for (unsigned int jtrk = itrk + 1; jtrk < numTrk; jtrk++) {
508  // Skip duplicate tracks
509  if (inputtracks_[jtrk]->duplicate() == 1)
510  continue;
511 
512  // Chi2 duplicate removal
513  if (settings_.removalType() == "ichi") {
514  if ((nStubP - nShare[jtrk] < settings_.minIndStubs()) ||
515  (nStubS[jtrk] - nShare[jtrk] < settings_.minIndStubs())) {
516  if ((int)inputtracks_[itrk]->ichisq() / (2 * inputtracks_[itrk]->stubID().size() - 4) >
517  (int)inputtracks_[jtrk]->ichisq() / (2 * inputtracks_[itrk]->stubID().size() - 4)) {
518  inputtracks_[itrk]->setDuplicate(true);
519  } else if ((int)inputtracks_[itrk]->ichisq() / (2 * inputtracks_[itrk]->stubID().size() - 4) <=
520  (int)inputtracks_[jtrk]->ichisq() / (2 * inputtracks_[itrk]->stubID().size() - 4)) {
521  inputtracks_[jtrk]->setDuplicate(true);
522  } else {
523  edm::LogVerbatim("Tracklet") << "Error: Didn't tag either track in duplicate pair.";
524  }
525  }
526  } // end ichi removal
527 
528  // nStub duplicate removal
529  if (settings_.removalType() == "nstub") {
530  if ((nStubP - nShare[jtrk] < settings_.minIndStubs()) && (nStubP < nStubS[jtrk])) {
531  inputtracks_[itrk]->setDuplicate(true);
532  } else if ((nStubS[jtrk] - nShare[jtrk] < settings_.minIndStubs()) && (nStubS[jtrk] <= nStubP)) {
533  inputtracks_[jtrk]->setDuplicate(true);
534  } else {
535  edm::LogVerbatim("Tracklet") << "Error: Didn't tag either track in duplicate pair.";
536  }
537  } // end nstub removal
538 
539  } // end tag duplicates
540 
541  } // end loop over primary track
542 
543  } // end ichi + nstub removal
544 
545  //Add tracks to output
546  if (settings_.removalType() != "merge") {
547  for (unsigned int i = 0; i < inputtrackfits_.size(); i++) {
548  for (unsigned int j = 0; j < inputtrackfits_[i]->nTracks(); j++) {
549  if (inputtrackfits_[i]->getTrack(j)->getTrack()->duplicate() == 0) {
550  if (settings_.writeMonitorData("Seeds")) {
551  ofstream fout("seeds.txt", ofstream::app);
552  fout << __FILE__ << ":" << __LINE__ << " " << name_ << "_" << iSector << " "
553  << inputtrackfits_[i]->getTrack(j)->getISeed() << endl;
554  fout.close();
555  }
556  outputtracklets_[i]->addTrack(inputtrackfits_[i]->getTrack(j));
557  }
558  //For root file:
559  outputtracks.push_back(*inputtrackfits_[i]->getTrack(j)->getTrack());
560  }
561  }
562  }
563 }
size
Write out results.
Log< level::Info, true > LogVerbatim
unsigned int seedIndex() const
Definition: Tracklet.h:226
unsigned int maxStep(std::string module) const
Definition: Settings.h:125
std::string name_
Definition: ProcessBase.h:38
std::vector< std::vector< std::pair< int, int > > > inputstubidslists_
Settings const & settings_
Definition: ProcessBase.h:40
Globals * globals_
Definition: ProcessBase.h:41
double getPhiRes(Tracklet *curTracklet, const Stub *curStub) const
std::vector< CleanTrackMemory * > outputtracklets_
unsigned int minIndStubs() const
Definition: Settings.h:250
void find(edm::Handle< EcalRecHitCollection > &hits, DetId thisDet, std::vector< EcalRecHitCollection::const_iterator > &hit, bool debug=false)
Definition: FindCaloHit.cc:19
std::vector< Track * > inputtracks_
Track * getTrack()
Definition: Tracklet.h:192
bool fit() const
Definition: Tracklet.h:197
U second(std::pair< T, U > const &p)
const std::vector< double > & phiBins() const
Definition: Settings.h:304
std::vector< unsigned int > findOverlapPhiBins(const Tracklet *trk) const
unsigned int findPhiBin(const Tracklet *trk) const
unsigned int numTracksComparedPerBin() const
Definition: Settings.h:300
std::string removalType() const
Definition: Settings.h:251
std::vector< TrackFitMemory * > inputtrackfits_
bool writeMonitorData(std::string module) const
Definition: Settings.h:118
bool inventStubs() const
Definition: Settings.h:274
#define M_PI
bool isTrackInBin(const std::vector< unsigned int > &vec, unsigned int num) const
static const TrackGhostTrackState * getTrack(const BasicGhostTrackState *basic)
void setSector(int nsec)
Definition: Track.h:34
std::vector< unsigned int > findOverlapRinvBins(const Tracklet *trk) const
unsigned int findRinvBin(const Tracklet *trk) const
std::vector< Tracklet * > inputtracklets_
std::vector< std::vector< std::pair< int, int > > > mergedstubidslists_
std::string mergeComparison() const
Definition: Settings.h:252
bool extended() const
Definition: Settings.h:268
std::vector< const Stub * > getInventedSeedingStub(unsigned int, const Tracklet *, const std::vector< const Stub *> &) const
int ichisq() const
Definition: Track.h:40
std::vector< std::vector< const Stub * > > inputstublists_
int uniqueIndex(int eta, int phi)
const std::vector< double > & rinvBins() const
Definition: Settings.h:302
void setStubIDprefit(std::vector< std::pair< int, int >> stubIDprefit)
Definition: Track.h:36
const std::map< int, int > & stubID() const
Definition: Track.h:42
void setStubIDpremerge(std::vector< std::pair< int, int >> stubIDpremerge)
Definition: Track.h:35

◆ findLayerDisk()

std::pair< int, int > PurgeDuplicate::findLayerDisk ( const Stub st) const
private

Definition at line 609 of file PurgeDuplicate.cc.

References trklet::Stub::layerdisk(), and trklet::N_LAYER.

Referenced by getInventedCoords(), getInventedCoordsExtended(), and getInventedSeedingStub().

609  {
610  std::pair<int, int> layer_disk;
611  layer_disk.first = st->layerdisk() + 1;
612  if (layer_disk.first > N_LAYER) {
613  layer_disk.first = 0;
614  }
615  layer_disk.second = st->layerdisk() - (N_LAYER - 1);
616  if (layer_disk.second < 0) {
617  layer_disk.second = 0;
618  }
619  return layer_disk;
620 }
unsigned int layerdisk() const
Definition: Stub.cc:193
constexpr int N_LAYER
Definition: Settings.h:25

◆ findOverlapPhiBins()

std::vector< unsigned int > PurgeDuplicate::findOverlapPhiBins ( const Tracklet trk) const
private

Definition at line 830 of file PurgeDuplicate.cc.

References mps_fire::i, trklet::Tracklet::phi0(), l1tTrackJets_cfi::phiBins, trklet::Settings::phiBins(), trklet::Settings::phiOverlapSize(), trklet::Settings::rcrit(), trklet::rinv(), trklet::Tracklet::rinv(), and trklet::ProcessBase::settings_.

Referenced by execute().

830  {
831  double phi0 = trk->phi0();
832  double rcrit = settings_.rcrit();
833  double rinv = trk->rinv();
834  double phi = phi0 - asin(0.5 * rinv * rcrit);
835 
836  const double phiOverlapSize = settings_.phiOverlapSize();
837  const std::vector<double>& phiBins = settings_.phiBins();
838 
839  std::vector<unsigned int> chosenBins;
840  for (long unsigned int i = 0; i < phiBins.size() - 1; i++) {
841  if ((phi < phiBins[i + 1] + phiOverlapSize) && (phi > phiBins[i] - phiOverlapSize)) {
842  chosenBins.push_back(i);
843  }
844  }
845  return chosenBins;
846 }
Settings const & settings_
Definition: ProcessBase.h:40
double phi0() const
Definition: Tracklet.h:121
const std::vector< double > & phiBins() const
Definition: Settings.h:304
double rinv() const
Definition: Tracklet.h:120
double phiOverlapSize() const
Definition: Settings.h:298
double rinv(double phi1, double phi2, double r1, double r2)
Definition: Util.h:66
double rcrit() const
Definition: Settings.h:327

◆ findOverlapRinvBins()

std::vector< unsigned int > PurgeDuplicate::findOverlapRinvBins ( const Tracklet trk) const
private

Definition at line 814 of file PurgeDuplicate.cc.

References mps_fire::i, trklet::rinv(), trklet::Tracklet::rinv(), trklet::Settings::rinvBins(), trklet::Settings::rinvOverlapSize(), and trklet::ProcessBase::settings_.

Referenced by execute().

814  {
815  double rinv = trk->rinv();
816 
817  const double rinvOverlapSize = settings_.rinvOverlapSize();
818  const std::vector<double>& rinvBins = settings_.rinvBins();
819 
820  std::vector<unsigned int> chosenBins;
821  for (long unsigned int i = 0; i < rinvBins.size() - 1; i++) {
822  if ((rinv < rinvBins[i + 1] + rinvOverlapSize) && (rinv > rinvBins[i] - rinvOverlapSize)) {
823  chosenBins.push_back(i);
824  }
825  }
826  return chosenBins;
827 }
double rinvOverlapSize() const
Definition: Settings.h:296
Settings const & settings_
Definition: ProcessBase.h:40
double rinv() const
Definition: Tracklet.h:120
double rinv(double phi1, double phi2, double r1, double r2)
Definition: Util.h:66
const std::vector< double > & rinvBins() const
Definition: Settings.h:302

◆ findPhiBin()

unsigned int PurgeDuplicate::findPhiBin ( const Tracklet trk) const
private

Definition at line 791 of file PurgeDuplicate.cc.

References trigObjTnPSource_cfi::bins, HLT_2024v11_cff::distance, trklet::Tracklet::phi0(), l1tTrackJets_cfi::phiBins, trklet::Settings::phiBins(), trklet::Settings::rcrit(), trklet::rinv(), trklet::Tracklet::rinv(), trklet::ProcessBase::settings_, and pfDeepBoostedJetPreprocessParams_cfi::upper_bound.

Referenced by execute().

791  {
792  std::vector<double> phiBins = settings_.phiBins();
793 
794  //Get phi of track at rcrit
795  double phi0 = trk->phi0();
796  double rcrit = settings_.rcrit();
797  double rinv = trk->rinv();
798  double phi = phi0 - asin(0.5 * rinv * rcrit);
799 
800  //Check between what 2 values in phibins phi is between
801  auto bins = std::upper_bound(phiBins.begin(), phiBins.end(), phi);
802 
803  //return integer for bin index
804  unsigned int phiIndx = std::distance(phiBins.begin(), bins);
805  if (phiIndx == std::distance(phiBins.end(), bins))
806  return phiBins.size() - 2;
807  else if (bins == phiBins.begin())
808  return std::distance(phiBins.begin(), bins);
809  else
810  return phiIndx - 1;
811 }
Settings const & settings_
Definition: ProcessBase.h:40
double phi0() const
Definition: Tracklet.h:121
const std::vector< double > & phiBins() const
Definition: Settings.h:304
double rinv() const
Definition: Tracklet.h:120
double rinv(double phi1, double phi2, double r1, double r2)
Definition: Util.h:66
double rcrit() const
Definition: Settings.h:327

◆ findRinvBin()

unsigned int PurgeDuplicate::findRinvBin ( const Tracklet trk) const
private

Definition at line 771 of file PurgeDuplicate.cc.

References trigObjTnPSource_cfi::bins, HLT_2024v11_cff::distance, trklet::rinv(), trklet::Tracklet::rinv(), trklet::Settings::rinvBins(), trklet::ProcessBase::settings_, and pfDeepBoostedJetPreprocessParams_cfi::upper_bound.

Referenced by execute().

771  {
772  std::vector<double> rinvBins = settings_.rinvBins();
773 
774  //Get rinverse of track
775  double rinv = trk->rinv();
776 
777  //Check between what 2 values in rinvbins rinv is between
778  auto bins = std::upper_bound(rinvBins.begin(), rinvBins.end(), rinv);
779 
780  //return integer for bin index
781  unsigned int rIndx = std::distance(rinvBins.begin(), bins);
782  if (rIndx == std::distance(rinvBins.end(), bins))
783  return rinvBins.size() - 2;
784  else if (bins == rinvBins.begin())
785  return std::distance(rinvBins.begin(), bins);
786  else
787  return rIndx - 1;
788 }
Settings const & settings_
Definition: ProcessBase.h:40
double rinv() const
Definition: Tracklet.h:120
double rinv(double phi1, double phi2, double r1, double r2)
Definition: Util.h:66
const std::vector< double > & rinvBins() const
Definition: Settings.h:302

◆ getInventedCoords()

std::vector< double > PurgeDuplicate::getInventedCoords ( unsigned int  iSector,
const Stub st,
const Tracklet tracklet 
) const
private

Definition at line 635 of file PurgeDuplicate.cc.

References funct::abs(), trklet::Tracklet::disk(), trklet::Settings::dphisector(), trklet::Settings::dphisectorHG(), findLayerDisk(), dqmdumpme::first, trklet::Stub::isBarrel(), trklet::Tracklet::phi0(), reco::reduceRange(), trklet::Tracklet::rinv(), trklet::Settings::rmean(), edm::second(), trklet::ProcessBase::settings_, funct::sin(), trklet::Tracklet::t(), trklet::Tracklet::z0(), and trklet::Settings::zmean().

Referenced by getInventedSeedingStub().

637  {
638  int stubLayer = (findLayerDisk(st)).first;
639  int stubDisk = (findLayerDisk(st)).second;
640 
641  double stub_phi = -99;
642  double stub_z = -99;
643  double stub_r = -99;
644 
645  double tracklet_rinv = tracklet->rinv();
646 
647  if (st->isBarrel()) {
648  stub_r = settings_.rmean(stubLayer - 1);
649  stub_phi = tracklet->phi0() - std::asin(stub_r * tracklet_rinv / 2);
650  stub_phi = stub_phi + iSector * settings_.dphisector() - 0.5 * settings_.dphisectorHG();
651  stub_phi = reco::reduceRange(stub_phi);
652  stub_z = tracklet->z0() + 2 * tracklet->t() * 1 / tracklet_rinv * std::asin(stub_r * tracklet_rinv / 2);
653  } else {
654  stub_z = settings_.zmean(stubDisk - 1) * tracklet->disk() / abs(tracklet->disk());
655  stub_phi = tracklet->phi0() - (stub_z - tracklet->z0()) * tracklet_rinv / 2 / tracklet->t();
656  stub_phi = stub_phi + iSector * settings_.dphisector() - 0.5 * settings_.dphisectorHG();
657  stub_phi = reco::reduceRange(stub_phi);
658  stub_r = 2 / tracklet_rinv * std::sin((stub_z - tracklet->z0()) * tracklet_rinv / 2 / tracklet->t());
659  }
660 
661  std::vector<double> invented_coords{stub_r, stub_z, stub_phi};
662  return invented_coords;
663 }
double t() const
Definition: Tracklet.h:123
int disk() const
Definition: Tracklet.cc:801
constexpr T reduceRange(T x)
Definition: deltaPhi.h:18
double dphisectorHG() const
Definition: Settings.h:320
Sin< T >::type sin(const T &t)
Definition: Sin.h:22
bool isBarrel() const
Definition: Stub.h:87
Settings const & settings_
Definition: ProcessBase.h:40
double phi0() const
Definition: Tracklet.h:121
U second(std::pair< T, U > const &p)
double dphisector() const
Definition: Settings.h:329
double rmean(unsigned int iLayer) const
Definition: Settings.h:173
double rinv() const
Definition: Tracklet.h:120
Abs< T >::type abs(const T &t)
Definition: Abs.h:22
double zmean(unsigned int iDisk) const
Definition: Settings.h:176
std::pair< int, int > findLayerDisk(const Stub *) const
double z0() const
Definition: Tracklet.h:124

◆ getInventedCoordsExtended()

std::vector< double > PurgeDuplicate::getInventedCoordsExtended ( unsigned int  iSector,
const Stub st,
const Tracklet tracklet 
) const
private

Definition at line 665 of file PurgeDuplicate.cc.

References funct::abs(), HLT_2024v11_cff::beta, funct::cos(), trklet::Tracklet::d0(), trklet::D1D2L2, trklet::Tracklet::disk(), trklet::Settings::dphisector(), trklet::Settings::dphisectorHG(), findLayerDisk(), dqmdumpme::first, trklet::Stub::isBarrel(), trklet::Stub::l1tstub(), trklet::L2L3D1, trklet::L2L3L4, trklet::L4L5L6, SiStripPI::max, SiStripPI::min, trklet::L1TStub::phi(), trklet::Tracklet::phi0(), trklet::L1TStub::r(), reco::reduceRange(), trklet::Tracklet::rinv(), trklet::Settings::rmean(), edm::second(), fileCollector::seed, trklet::Tracklet::seedIndex(), trklet::ProcessBase::settings_, mathSSE::sqrt(), trklet::Tracklet::t(), trklet::L1TStub::z(), trklet::Tracklet::z0(), and trklet::Settings::zmean().

Referenced by getInventedSeedingStub().

667  {
668  const int stubLayer = (findLayerDisk(st)).first;
669  const int stubDisk = (findLayerDisk(st)).second;
670 
671  double stub_phi = -99;
672  double stub_z = -99;
673  double stub_r = -99;
674 
675  const double rho = 1 / tracklet->rinv();
676  const double rho_minus_d0 = rho + tracklet->d0(); // should be -, but otherwise does not work
677 
678  const int seed = tracklet->seedIndex();
679 
680  // TMP: for displaced tracking, exclude one of the 3 seeding stubs
681  // to be discussed
682  if ((seed == L2L3L4 && stubLayer == 4) || (seed == L4L5L6 && stubLayer == 5) ||
683  (seed == L2L3D1 && abs(stubDisk) == 1) || (seed == D1D2L2 && abs(stubDisk) == 1)) {
684  stub_phi = st->l1tstub()->phi();
685  stub_z = st->l1tstub()->z();
686  stub_r = st->l1tstub()->r();
687  } else {
688  // exact helix
689  if (st->isBarrel()) {
690  stub_r = settings_.rmean(stubLayer - 1);
691 
692  // The expanded version of this expression is more stable for extremely
693  // high-pT (high-rho) tracks. But we also explicitly restrict sin_val to
694  // the domain of asin.
695  double sin_val =
696  0.5 * (stub_r / rho_minus_d0) + 0.5 * (rho_minus_d0 / stub_r) - 0.5 * ((rho * rho) / (rho_minus_d0 * stub_r));
697  sin_val = std::max(std::min(sin_val, 1.0), -1.0);
698  stub_phi = tracklet->phi0() - std::asin(sin_val);
699  stub_phi = stub_phi + iSector * settings_.dphisector() - 0.5 * settings_.dphisectorHG();
700  stub_phi = reco::reduceRange(stub_phi);
701 
702  // The expanded version of this expression is more stable for extremely
703  // high-pT (high-rho) tracks. But we also explicitly restrict cos_val to
704  // the domain of acos.
705  double cos_val =
706  0.5 * (rho / rho_minus_d0) + 0.5 * (rho_minus_d0 / rho) - 0.5 * ((stub_r * stub_r) / (rho * rho_minus_d0));
707  cos_val = std::max(std::min(cos_val, 1.0), -1.0);
708  double beta = std::acos(cos_val);
709  stub_z = tracklet->z0() + tracklet->t() * std::abs(rho * beta);
710  } else {
711  stub_z = settings_.zmean(stubDisk - 1) * tracklet->disk() / abs(tracklet->disk());
712 
713  double beta = (stub_z - tracklet->z0()) / (tracklet->t() * std::abs(rho)); // maybe rho should be abs value
714  double r_square = -2 * rho * rho_minus_d0 * std::cos(beta) + rho * rho + rho_minus_d0 * rho_minus_d0;
715  stub_r = sqrt(r_square);
716 
717  // The expanded version of this expression is more stable for extremely
718  // high-pT (high-rho) tracks. But we also explicitly restrict sin_val to
719  // the domain of asin.
720  double sin_val =
721  0.5 * (stub_r / rho_minus_d0) + 0.5 * (rho_minus_d0 / stub_r) - 0.5 * ((rho * rho) / (rho_minus_d0 * stub_r));
722  sin_val = std::max(std::min(sin_val, 1.0), -1.0);
723  stub_phi = tracklet->phi0() - std::asin(sin_val);
724  stub_phi = stub_phi + iSector * settings_.dphisector() - 0.5 * settings_.dphisectorHG();
725  stub_phi = reco::reduceRange(stub_phi);
726  }
727  }
728 
729  std::vector<double> invented_coords{stub_r, stub_z, stub_phi};
730  return invented_coords;
731 }
unsigned int seedIndex() const
Definition: Tracklet.h:226
double phi() const
Definition: L1TStub.h:65
double t() const
Definition: Tracklet.h:123
int disk() const
Definition: Tracklet.cc:801
constexpr T reduceRange(T x)
Definition: deltaPhi.h:18
double dphisectorHG() const
Definition: Settings.h:320
bool isBarrel() const
Definition: Stub.h:87
Settings const & settings_
Definition: ProcessBase.h:40
double phi0() const
Definition: Tracklet.h:121
double z() const
Definition: L1TStub.h:59
U second(std::pair< T, U > const &p)
double dphisector() const
Definition: Settings.h:329
double rmean(unsigned int iLayer) const
Definition: Settings.h:173
double rinv() const
Definition: Tracklet.h:120
T sqrt(T t)
Definition: SSEVec.h:19
Cos< T >::type cos(const T &t)
Definition: Cos.h:22
Abs< T >::type abs(const T &t)
Definition: Abs.h:22
L1TStub * l1tstub()
Definition: Stub.h:83
double zmean(unsigned int iDisk) const
Definition: Settings.h:176
std::pair< int, int > findLayerDisk(const Stub *) const
double d0() const
Definition: Tracklet.h:122
double z0() const
Definition: Tracklet.h:124
double r() const
Definition: L1TStub.h:60

◆ getInventedSeedingStub()

std::vector< const Stub * > PurgeDuplicate::getInventedSeedingStub ( unsigned int  iSector,
const Tracklet tracklet,
const std::vector< const Stub *> &  originalStubsList 
) const
private

Definition at line 733 of file PurgeDuplicate.cc.

References trklet::L1TStub::allStubIndex(), funct::cos(), trklet::Settings::extended(), findLayerDisk(), dqmdumpme::first, getInventedCoords(), getInventedCoordsExtended(), isSeedingStub(), trklet::Stub::l1tstub(), edm::second(), trklet::Tracklet::seedIndex(), trklet::L1TStub::setAllStubIndex(), trklet::L1TStub::setCoords(), trklet::Stub::setl1tstub(), trklet::ProcessBase::settings_, trklet::L1TStub::setUniqueIndex(), funct::sin(), and trklet::L1TStub::uniqueIndex().

Referenced by execute().

734  {
735  std::vector<const Stub*> newStubList;
736 
737  for (unsigned int stubit = 0; stubit < originalStubsList.size(); stubit++) {
738  const Stub* thisStub = originalStubsList[stubit];
739 
740  if (isSeedingStub(tracklet->seedIndex(), (findLayerDisk(thisStub)).first, (findLayerDisk(thisStub)).second)) {
741  // get a vector containing r, z, phi
742  std::vector<double> inv_r_z_phi;
743  if (!settings_.extended())
744  inv_r_z_phi = getInventedCoords(iSector, thisStub, tracklet);
745  else {
746  inv_r_z_phi = getInventedCoordsExtended(iSector, thisStub, tracklet);
747  }
748  double stub_x_invent = inv_r_z_phi[0] * std::cos(inv_r_z_phi[2]);
749  double stub_y_invent = inv_r_z_phi[0] * std::sin(inv_r_z_phi[2]);
750  double stub_z_invent = inv_r_z_phi[1];
751 
752  Stub* invent_stub_ptr = new Stub(*thisStub);
753  const L1TStub* l1stub = thisStub->l1tstub();
754  L1TStub invent_l1stub = *l1stub;
755  invent_l1stub.setCoords(stub_x_invent, stub_y_invent, stub_z_invent);
756 
757  invent_stub_ptr->setl1tstub(new L1TStub(invent_l1stub));
758  invent_stub_ptr->l1tstub()->setAllStubIndex(l1stub->allStubIndex());
759  invent_stub_ptr->l1tstub()->setUniqueIndex(l1stub->uniqueIndex());
760 
761  newStubList.push_back(invent_stub_ptr);
762 
763  } else {
764  newStubList.push_back(thisStub);
765  }
766  }
767  return newStubList;
768 }
unsigned int seedIndex() const
Definition: Tracklet.h:226
Sin< T >::type sin(const T &t)
Definition: Sin.h:22
Settings const & settings_
Definition: ProcessBase.h:40
U second(std::pair< T, U > const &p)
std::vector< double > getInventedCoords(unsigned int, const Stub *, const Tracklet *) const
std::vector< double > getInventedCoordsExtended(unsigned int, const Stub *, const Tracklet *) const
Cos< T >::type cos(const T &t)
Definition: Cos.h:22
L1TStub * l1tstub()
Definition: Stub.h:83
void setUniqueIndex(unsigned int index)
Definition: L1TStub.h:84
unsigned int allStubIndex() const
Definition: L1TStub.h:91
std::pair< int, int > findLayerDisk(const Stub *) const
void setCoords(double x, double y, double z)
Definition: L1TStub.h:85
bool extended() const
Definition: Settings.h:268
void setl1tstub(L1TStub *l1tstub)
Definition: Stub.h:85
void setAllStubIndex(unsigned int index)
Definition: L1TStub.h:83
bool isSeedingStub(int, int, int) const
unsigned int uniqueIndex() const
Definition: L1TStub.h:92

◆ getPhiRes()

double PurgeDuplicate::getPhiRes ( Tracklet curTracklet,
const Stub curStub 
) const
private

Definition at line 565 of file PurgeDuplicate.cc.

References funct::abs(), isSeedingStub(), trklet::Stub::l1tstub(), trklet::Stub::layerdisk(), trklet::N_LAYER, trklet::L1TStub::phi(), trklet::Tracklet::proj(), and trklet::Tracklet::seedIndex().

Referenced by execute().

565  {
566  double phiproj;
567  double stubphi;
568  double phires;
569  // Get phi position of stub
570  stubphi = curStub->l1tstub()->phi();
571  // Get layer that the stub is in (Layer 1->6, Disk 1->5)
572  int Layer = curStub->layerdisk() + 1;
573  if (Layer > N_LAYER) {
574  Layer = 0;
575  }
576  int Disk = curStub->layerdisk() - (N_LAYER - 1);
577  if (Disk < 0) {
578  Disk = 0;
579  }
580  // Get phi projection of tracklet
581  int seedindex = curTracklet->seedIndex();
582  // If this stub is a seed stub, set projection=phi, so that res=0
583  if (isSeedingStub(seedindex, Layer, Disk)) {
584  phiproj = stubphi;
585  // Otherwise, get projection of tracklet
586  } else {
587  phiproj = curTracklet->proj(curStub->layerdisk()).phiproj();
588  }
589  // Calculate residual
590  phires = std::abs(stubphi - phiproj);
591  return phires;
592 }
unsigned int seedIndex() const
Definition: Tracklet.h:226
double phi() const
Definition: L1TStub.h:65
Projection & proj(int layerdisk)
Definition: Tracklet.h:87
SeedingLayerSetsHits::SeedingLayer Layer
Definition: LayerTriplets.h:14
Definition: BoundDisk.h:19
Abs< T >::type abs(const T &t)
Definition: Abs.h:22
L1TStub * l1tstub()
Definition: Stub.h:83
unsigned int layerdisk() const
Definition: Stub.cc:193
bool isSeedingStub(int, int, int) const
constexpr int N_LAYER
Definition: Settings.h:25

◆ isSeedingStub()

bool PurgeDuplicate::isSeedingStub ( int  seedindex,
int  Layer,
int  Disk 
) const
private

Definition at line 594 of file PurgeDuplicate.cc.

References funct::abs().

Referenced by getInventedSeedingStub(), and getPhiRes().

594  {
595  if ((seedindex == 0 && (Layer == 1 || Layer == 2)) || (seedindex == 1 && (Layer == 2 || Layer == 3)) ||
596  (seedindex == 2 && (Layer == 3 || Layer == 4)) || (seedindex == 3 && (Layer == 5 || Layer == 6)) ||
597  (seedindex == 4 && (abs(Disk) == 1 || abs(Disk) == 2)) ||
598  (seedindex == 5 && (abs(Disk) == 3 || abs(Disk) == 4)) || (seedindex == 6 && (Layer == 1 || abs(Disk) == 1)) ||
599  (seedindex == 7 && (Layer == 2 || abs(Disk) == 1)) ||
600  (seedindex == 8 && (Layer == 2 || Layer == 3 || Layer == 4)) ||
601  (seedindex == 9 && (Layer == 4 || Layer == 5 || Layer == 6)) ||
602  (seedindex == 10 && (Layer == 2 || Layer == 3 || abs(Disk) == 1)) ||
603  (seedindex == 11 && (Layer == 2 || abs(Disk) == 1 || abs(Disk) == 2)))
604  return true;
605 
606  return false;
607 }
SeedingLayerSetsHits::SeedingLayer Layer
Definition: LayerTriplets.h:14
Definition: BoundDisk.h:19
Abs< T >::type abs(const T &t)
Definition: Abs.h:22

◆ isTrackInBin()

bool PurgeDuplicate::isTrackInBin ( const std::vector< unsigned int > &  vec,
unsigned int  num 
) const
private

Definition at line 849 of file PurgeDuplicate.cc.

References spr::find(), newFWLiteAna::found, EgammaValidation_cff::num, and mps_fire::result.

Referenced by execute().

849  {
850  auto result = std::find(vec.begin(), vec.end(), num);
851  bool found = (result != vec.end());
852  return found;
853 }
void find(edm::Handle< EcalRecHitCollection > &hits, DetId thisDet, std::vector< EcalRecHitCollection::const_iterator > &hit, bool debug=false)
Definition: FindCaloHit.cc:19

◆ l1tinfo()

std::string PurgeDuplicate::l1tinfo ( const L1TStub l1stub,
std::string  str = "" 
) const
private

Definition at line 622 of file PurgeDuplicate.cc.

References trklet::L1TStub::bend(), trklet::L1TStub::iphi(), trklet::L1TStub::layerdisk(), trklet::L1TStub::phi(), trklet::L1TStub::r(), str, AlCaHLTBitMon_QueryRunRegistry::string, and trklet::L1TStub::z().

622  {
623  // Uses ROOT::TString
624  std::string thestr = Form("\t %s stub info: r/z/phi:\t%f\t%f\t%f\t%d\t%f\t%d",
625  str.c_str(),
626  l1stub->r(),
627  l1stub->z(),
628  l1stub->phi(),
629  l1stub->iphi(),
630  l1stub->bend(),
631  l1stub->layerdisk());
632  return thestr;
633 }
double phi() const
Definition: L1TStub.h:65
double bend() const
Definition: L1TStub.h:63
double z() const
Definition: L1TStub.h:59
int layerdisk() const
Definition: L1TStub.h:119
double r() const
Definition: L1TStub.h:60
unsigned int iphi() const
Definition: L1TStub.h:67
#define str(s)

Member Data Documentation

◆ inputstubidslists_

std::vector<std::vector<std::pair<int, int> > > trklet::PurgeDuplicate::inputstubidslists_
private

Definition at line 64 of file PurgeDuplicate.h.

Referenced by execute().

◆ inputstublists_

std::vector<std::vector<const Stub*> > trklet::PurgeDuplicate::inputstublists_
private

Definition at line 63 of file PurgeDuplicate.h.

Referenced by execute().

◆ inputtrackfits_

std::vector<TrackFitMemory*> trklet::PurgeDuplicate::inputtrackfits_
private

Definition at line 66 of file PurgeDuplicate.h.

Referenced by addInput(), and execute().

◆ inputtracklets_

std::vector<Tracklet*> trklet::PurgeDuplicate::inputtracklets_
private

Definition at line 67 of file PurgeDuplicate.h.

Referenced by execute().

◆ inputtracks_

std::vector<Track*> trklet::PurgeDuplicate::inputtracks_
private

Definition at line 62 of file PurgeDuplicate.h.

Referenced by execute().

◆ mergedstubidslists_

std::vector<std::vector<std::pair<int, int> > > trklet::PurgeDuplicate::mergedstubidslists_
private

Definition at line 65 of file PurgeDuplicate.h.

Referenced by execute().

◆ outputtracklets_

std::vector<CleanTrackMemory*> trklet::PurgeDuplicate::outputtracklets_
private

Definition at line 68 of file PurgeDuplicate.h.

Referenced by addOutput(), and execute().