CMS 3D CMS Logo

TrackingNtuple.cc
Go to the documentation of this file.
1 // -*- C++ -*-
2 //
3 // Package: NtupleDump/TrackingNtuple
4 // Class: TrackingNtuple
5 //
13 //
14 // Original Author: Giuseppe Cerati
15 // Created: Tue, 25 Aug 2015 13:22:49 GMT
16 //
17 //
18 
19 
20 // system include files
21 #include <memory>
22 
23 // user include files
26 
36 
39 
42 
46 
53 
56 
62 
67 
70 
79 
82 
84 #include "HepPDT/ParticleID.hh"
85 
87 
88 #include <set>
89 #include <map>
90 #include <unordered_set>
91 #include <unordered_map>
92 #include <tuple>
93 #include <utility>
94 
95 #include "TTree.h"
96 
97 /*
98 todo:
99 add refitted hit position after track/seed fit
100 add local angle, path length!
101 */
102 
103 namespace {
104  std::string subdetstring(int subdet) {
105  switch(subdet) {
106  case StripSubdetector::TIB: return "- TIB";
107  case StripSubdetector::TOB: return "- TOB";
108  case StripSubdetector::TEC: return "- TEC";
109  case StripSubdetector::TID: return "- TID";
110  case PixelSubdetector::PixelBarrel: return "- PixBar";
111  case PixelSubdetector::PixelEndcap: return "- PixFwd";
112  default: return "UNKNOWN TRACKER HIT TYPE";
113  }
114  }
115 
116  struct ProductIDSetPrinter {
117  ProductIDSetPrinter(const std::set<edm::ProductID>& set): set_(set) {}
118 
119  void print(std::ostream& os) const {
120  for(const auto& item: set_) {
121  os << item << " ";
122  }
123  }
124 
125  const std::set<edm::ProductID>& set_;
126  };
127  std::ostream& operator<<(std::ostream& os, const ProductIDSetPrinter& o) {
128  o.print(os);
129  return os;
130  }
131  template <typename T>
132  struct ProductIDMapPrinter {
133  ProductIDMapPrinter(const std::map<edm::ProductID, T>& map): map_(map) {}
134 
135  void print(std::ostream& os) const {
136  for(const auto& item: map_) {
137  os << item.first << " ";
138  }
139  }
140 
141  const std::map<edm::ProductID, T>& map_;
142  };
143  template <typename T>
144  auto make_ProductIDMapPrinter(const std::map<edm::ProductID, T>& map) {
145  return ProductIDMapPrinter<T>(map);
146  }
147  template <typename T>
148  std::ostream& operator<<(std::ostream& os, const ProductIDMapPrinter<T>& o) {
149  o.print(os);
150  return os;
151  }
152 
153  template <typename T>
154  struct VectorPrinter {
155  VectorPrinter(const std::vector<T>& vec): vec_(vec) {}
156 
157  void print(std::ostream& os) const {
158  for(const auto& item: vec_) {
159  os << item << " ";
160  }
161  }
162 
163  const std::vector<T>& vec_;
164  };
165  template <typename T>
166  auto make_VectorPrinter(const std::vector<T>& vec) {
167  return VectorPrinter<T>(vec);
168  }
169  template <typename T>
170  std::ostream& operator<<(std::ostream& os, const VectorPrinter<T>& o) {
171  o.print(os);
172  return os;
173  }
174 
175  void checkProductID(const std::set<edm::ProductID>& set, const edm::ProductID& id, const char *name) {
176  if(set.find(id) == set.end())
177  throw cms::Exception("Configuration") << "Got " << name << " with a hit with ProductID " << id
178  << " which does not match to the set of ProductID's for the hits: "
179  << ProductIDSetPrinter(set)
180  << ". Usually this is caused by a wrong hit collection in the configuration.";
181  }
182 
183  template <typename SimLink, typename Func>
184  void forEachMatchedSimLink(const edm::DetSet<SimLink>& digiSimLinks, uint32_t channel, Func func) {
185  for(const auto& link: digiSimLinks) {
186  if(link.channel() == channel) {
187  func(link);
188  }
189  }
190  }
191 
192 
194  template <typename ...Args> void call_nop(Args&&... args) {}
195 
196  template <typename ...Types>
197  class CombineDetId {
198  public:
199  CombineDetId() {}
200 
203  unsigned int operator[](size_t i) const {
204  return std::get<0>(content_)[i];
205  }
206 
207  template <typename ...Args>
208  void book(Args&&... args) {
209  impl([&](auto& vec) { vec.book(std::forward<Args>(args)...); });
210  }
211 
212  template <typename ...Args>
213  void push_back(Args&&... args) {
214  impl([&](auto& vec) { vec.push_back(std::forward<Args>(args)...); });
215  }
216 
217  template <typename ...Args>
218  void resize(Args&&... args) {
219  impl([&](auto& vec) { vec.resize(std::forward<Args>(args)...); });
220  }
221 
222  template <typename ...Args>
223  void set(Args&&... args) {
224  impl([&](auto& vec) { vec.set(std::forward<Args>(args)...); });
225  }
226 
227  void clear() {
228  impl([&](auto& vec) { vec.clear(); });
229  }
230 
231  private:
232  // Trick to not repeate std::index_sequence_for in each of the methods above
233  template <typename F>
234  void impl(F&& func) {
235  impl2(std::index_sequence_for<Types...>{}, std::forward<F>(func));
236  }
237 
238  // Trick to exploit parameter pack expansion in function call
239  // arguments to call a member function for each tuple element
240  // (with the same signature). The comma operator is needed to
241  // return a value from the expression as an argument for the
242  // call_nop.
243  template <std::size_t ...Is, typename F>
244  void impl2(std::index_sequence<Is...>, F&& func) {
245  call_nop( (func(std::get<Is>(content_)) , 0)...);
246  }
247 
248  std::tuple<Types...> content_;
249  };
250 
251 
252  std::map<unsigned int, double> chargeFraction(const SiPixelCluster& cluster, const DetId& detId,
253  const edm::DetSetVector<PixelDigiSimLink>& digiSimLink) {
254  std::map<unsigned int, double> simTrackIdToAdc;
255 
256  auto idetset = digiSimLink.find(detId);
257  if(idetset == digiSimLink.end())
258  return simTrackIdToAdc;
259 
260  double adcSum = 0;
262  for(int iPix=0; iPix != cluster.size(); ++iPix) {
263  const SiPixelCluster::Pixel& pixel = cluster.pixel(iPix);
264  adcSum += pixel.adc;
265  uint32_t channel = PixelChannelIdentifier::pixelToChannel(pixel.x, pixel.y);
266  forEachMatchedSimLink(*idetset, channel, [&](const PixelDigiSimLink& simLink){
267  double& adc = simTrackIdToAdc[simLink.SimTrackId()];
268  adc += pixel.adc*simLink.fraction();
269  });
270  }
271 
272  for(auto& pair: simTrackIdToAdc) {
273  if(adcSum == 0.)
274  pair.second = 0.;
275  else
276  pair.second /= adcSum;
277  }
278 
279  return simTrackIdToAdc;
280  }
281 
282  std::map<unsigned int, double> chargeFraction(const SiStripCluster& cluster, const DetId& detId,
283  const edm::DetSetVector<StripDigiSimLink>& digiSimLink) {
284  std::map<unsigned int, double> simTrackIdToAdc;
285 
286  auto idetset = digiSimLink.find(detId);
287  if(idetset == digiSimLink.end())
288  return simTrackIdToAdc;
289 
290  double adcSum = 0;
292  int first = cluster.firstStrip();
293  for(size_t i=0; i<cluster.amplitudes().size(); ++i) {
294  adcSum += cluster.amplitudes()[i];
295  forEachMatchedSimLink(*idetset, first+i, [&](const StripDigiSimLink& simLink){
296  double& adc = simTrackIdToAdc[simLink.SimTrackId()];
297  adc += cluster.amplitudes()[i]*simLink.fraction();
298  });
299 
300  for(const auto& pair: simTrackIdToAdc) {
301  simTrackIdToAdc[pair.first] = (adcSum != 0. ? pair.second/adcSum : 0.);
302  }
303 
304  }
305  return simTrackIdToAdc;
306  }
307 
308 
309  std::map<unsigned int, double> chargeFraction(const Phase2TrackerCluster1D& cluster, const DetId& detId,
310  const edm::DetSetVector<StripDigiSimLink>& digiSimLink) {
311  std::map<unsigned int, double> simTrackIdToAdc;
312  throw cms::Exception("LogicError") << "Not possible to use StripDigiSimLink with Phase2TrackerCluster1D! ";
313  return simTrackIdToAdc;
314  }
315 
316  //In the OT, there is no measurement of the charge, so no ADC value.
317  //Only in the SSA chip (so in PSs) you have one "threshold" flag that tells you if the charge of at least one strip in the cluster exceeded 1.2 MIPs.
318  std::map<unsigned int, double> chargeFraction(const Phase2TrackerCluster1D& cluster, const DetId& detId,
319  const edm::DetSetVector<PixelDigiSimLink>& digiSimLink) {
320  std::map<unsigned int, double> simTrackIdToAdc;
321  return simTrackIdToAdc;
322  }
323 
324 }
325 
326 //
327 // class declaration
328 //
329 
330 class TrackingNtuple : public edm::one::EDAnalyzer<edm::one::SharedResources> {
331 public:
332  explicit TrackingNtuple(const edm::ParameterSet&);
333  ~TrackingNtuple();
334 
335  static void fillDescriptions(edm::ConfigurationDescriptions& descriptions);
336 
337 
338 private:
339  virtual void analyze(const edm::Event&, const edm::EventSetup&) override;
340 
341  void clearVariables();
342 
343  // This pattern is copied from QuickTrackAssociatorByHitsImpl. If
344  // further needs arises, it wouldn't hurt to abstract it somehow.
345  typedef std::unordered_set<reco::RecoToSimCollection::index_type> TrackingParticleRefKeySet;
346  typedef std::unordered_map<reco::RecoToSimCollection::index_type, size_t> TrackingParticleRefKeyToIndex;
347  typedef TrackingParticleRefKeyToIndex TrackingVertexRefKeyToIndex;
348  typedef std::pair<TrackPSimHitRef::key_type, edm::ProductID> SimHitFullKey;
349  typedef std::map<SimHitFullKey, size_t> SimHitRefKeyToIndex;
350 
351  enum class HitType {
352  Pixel = 0,
353  Strip = 1,
354  Glued = 2,
355  Invalid = 3,
356  Phase2OT = 4,
357  Unknown = 99
358  };
359 
360  // This gives the "best" classification of a reco hit
361  // In case of reco hit mathing to multiple sim, smaller number is
362  // considered better
363  // To be kept in synch with class HitSimType in ntuple.py
364  enum class HitSimType {
365  Signal = 0,
366  ITPileup = 1,
367  OOTPileup = 2,
368  Noise = 3,
369  Unknown = 99
370  };
371 
372  struct TPHitIndex {
373  TPHitIndex(unsigned int tp=0, unsigned int simHit=0, float to=0, unsigned int id=0): tpKey(tp), simHitIdx(simHit), tof(to), detId(id) {}
374  unsigned int tpKey;
375  unsigned int simHitIdx;
376  float tof;
377  unsigned int detId;
378  };
379  static bool tpHitIndexListLess(const TPHitIndex& i, const TPHitIndex& j) { return (i.tpKey < j.tpKey); }
380  static bool tpHitIndexListLessSort(const TPHitIndex& i, const TPHitIndex& j) {
381  if(i.tpKey == j.tpKey) {
383  return i.detId < j.detId;
384  }
385  return i.tof < j.tof; // works as intended if either one is NaN
386  }
387  return i.tpKey < j.tpKey;
388  }
389 
390  void fillBeamSpot(const reco::BeamSpot& bs);
391  void fillPixelHits(const edm::Event& iEvent,
392  const ClusterTPAssociation& clusterToTPMap,
393  const TrackingParticleRefKeyToIndex& tpKeyToIndex,
395  const edm::DetSetVector<PixelDigiSimLink>& digiSimLink,
396  const TransientTrackingRecHitBuilder& theTTRHBuilder,
397  const TrackerTopology& tTopo,
398  const SimHitRefKeyToIndex& simHitRefKeyToIndex,
399  std::set<edm::ProductID>& hitProductIds
400  );
401 
402  void fillStripRphiStereoHits(const edm::Event& iEvent,
403  const ClusterTPAssociation& clusterToTPMap,
404  const TrackingParticleRefKeyToIndex& tpKeyToIndex,
406  const edm::DetSetVector<StripDigiSimLink>& digiSimLink,
407  const TransientTrackingRecHitBuilder& theTTRHBuilder,
408  const TrackerTopology& tTopo,
409  const SimHitRefKeyToIndex& simHitRefKeyToIndex,
410  std::set<edm::ProductID>& hitProductIds
411  );
412 
413  void fillStripMatchedHits(const edm::Event& iEvent,
414  const TransientTrackingRecHitBuilder& theTTRHBuilder,
415  const TrackerTopology& tTopo,
416  std::vector<std::pair<int, int> >& monoStereoClusterList
417  );
418 
419  void fillPhase2OTHits(const edm::Event& iEvent,
420  const ClusterTPAssociation& clusterToTPMap,
421  const TrackingParticleRefKeyToIndex& tpKeyToIndex,
423  const edm::DetSetVector<PixelDigiSimLink>& digiSimLink,
424  const TransientTrackingRecHitBuilder& theTTRHBuilder,
425  const TrackerTopology& tTopo,
426  const SimHitRefKeyToIndex& simHitRefKeyToIndex,
427  std::set<edm::ProductID>& hitProductIds
428  );
429 
430  void fillSeeds(const edm::Event& iEvent,
431  const TrackingParticleRefVector& tpCollection,
432  const TrackingParticleRefKeyToIndex& tpKeyToIndex,
433  const reco::BeamSpot& bs,
434  const reco::TrackToTrackingParticleAssociator& associatorByHits,
435  const TransientTrackingRecHitBuilder& theTTRHBuilder,
436  const MagneticField *theMF,
437  const std::vector<std::pair<int, int> >& monoStereoClusterList,
438  const std::set<edm::ProductID>& hitProductIds,
439  std::map<edm::ProductID, size_t>& seedToCollIndex
440  );
441 
443  const TrackingParticleRefVector& tpCollection,
444  const TrackingParticleRefKeyToIndex& tpKeyToIndex,
445  const reco::BeamSpot& bs,
446  const reco::TrackToTrackingParticleAssociator& associatorByHits,
447  const TransientTrackingRecHitBuilder& theTTRHBuilder,
448  const TrackerTopology& tTopo,
449  const std::set<edm::ProductID>& hitProductIds,
450  const std::map<edm::ProductID, size_t>& seedToCollIndex
451  );
452 
453  void fillSimHits(const TrackerGeometry& tracker,
454  const TrackingParticleRefKeyToIndex& tpKeyToIndex,
456  const TrackerTopology& tTopo,
457  SimHitRefKeyToIndex& simHitRefKeyToIndex,
458  std::vector<TPHitIndex>& tpHitList);
459 
460  void fillTrackingParticles(const edm::Event& iEvent, const edm::EventSetup& iSetup,
461  const edm::RefToBaseVector<reco::Track>& tracks,
462  const reco::BeamSpot& bs,
463  const TrackingParticleRefVector& tpCollection,
464  const TrackingVertexRefKeyToIndex& tvKeyToIndex,
465  const reco::TrackToTrackingParticleAssociator& associatorByHits,
466  const std::vector<TPHitIndex>& tpHitList
467  );
468 
469  void fillTrackingParticlesForSeeds(const TrackingParticleRefVector& tpCollection,
470  const reco::SimToRecoCollection& simRecColl,
471  const TrackingParticleRefKeyToIndex& tpKeyToIndex,
472  const unsigned int seedOffset
473  );
474 
475  void fillVertices(const reco::VertexCollection& vertices,
476  const edm::RefToBaseVector<reco::Track>& tracks);
477 
478  void fillTrackingVertices(const TrackingVertexRefVector& trackingVertices,
479  const TrackingParticleRefKeyToIndex& tpKeyToIndex
480  );
481 
482 
483 
484  struct SimHitData {
485  std::vector<int> matchingSimHit;
486  std::vector<float> chargeFraction;
487  std::vector<int> bunchCrossing;
488  std::vector<int> event;
490  };
491 
492  template <typename SimLink>
493  SimHitData matchCluster(const OmniClusterRef& cluster,
494  DetId hitId, int clusterKey,
496  const ClusterTPAssociation& clusterToTPMap,
497  const TrackingParticleRefKeyToIndex& tpKeyToIndex,
499  const edm::DetSetVector<SimLink>& digiSimLinks,
500  const SimHitRefKeyToIndex& simHitRefKeyToIndex,
501  HitType hitType
502  );
503 
504  // ----------member data ---------------------------
505  std::vector<edm::EDGetTokenT<edm::View<reco::Track> > > seedTokens_;
506  std::vector<edm::EDGetTokenT<std::vector<short> > > seedStopReasonTokens_;
516  bool includeStripHits_, includePhase2OTHits_;
530  const bool includeSeeds_;
531  const bool includeAllHits_;
532 
534 
535  TTree* t;
536 
537  // DetId branches
538 #define BOOK(name) tree->Branch((prefix+"_"+#name).c_str(), &name);
539  class DetIdCommon {
540  public:
542 
543  unsigned int operator[](size_t i) const {
544  return detId[i];
545  }
546 
547  void book(const std::string& prefix, TTree *tree) {
548  BOOK(detId);
549  BOOK(subdet);
550  BOOK(layer);
551  BOOK(side);
552  BOOK(module);
553  }
554 
555  void push_back(const TrackerTopology& tTopo, const DetId& id) {
556  detId .push_back(id.rawId() );
557  subdet.push_back(id.subdetId() );
558  layer .push_back(tTopo.layer(id) );
559  module.push_back(tTopo.module(id));
560 
561  unsigned short s = 0;
562  switch(id.subdetId()) {
564  s = tTopo.tibSide(id);
565  break;
567  s = tTopo.tobSide(id);
568  break;
569  default:
570  s = tTopo.side(id);
571  }
572  side.push_back(s);
573  }
574 
575  void resize(size_t size) {
576  detId.resize(size);
577  subdet.resize(size);
578  layer.resize(size);
579  side.resize(size);
580  module.resize(size);
581  }
582 
583  void set(size_t index, const TrackerTopology& tTopo, const DetId& id) {
584  detId [index] = id.rawId();
585  subdet[index] = id.subdetId();
586  layer [index] = tTopo.layer(id);
587  side [index] = tTopo.side(id);
588  module[index] = tTopo.module(id);
589  }
590 
591  void clear() {
592  detId.clear();
593  subdet.clear();
594  layer.clear();
595  side.clear();
596  module.clear();
597  }
598 
599  private:
600  std::vector<unsigned int> detId;
601  std::vector<unsigned short> subdet;
602  std::vector<unsigned short> layer; // or disk/wheel
603  std::vector<unsigned short> side;
604  std::vector<unsigned short> module;
605  };
606 
608  public:
610 
611  void book(const std::string& prefix, TTree *tree) {
612  BOOK(ladder);
613  BOOK(blade);
614  BOOK(panel);
615  }
616 
617  void push_back(const TrackerTopology& tTopo, const DetId& id) {
618  const bool isBarrel = id.subdetId() == PixelSubdetector::PixelBarrel;
619  ladder.push_back( isBarrel ? tTopo.pxbLadder(id) : 0 );
620  blade .push_back( isBarrel ? 0 : tTopo.pxfBlade(id) );
621  panel .push_back( isBarrel ? 0 : tTopo.pxfPanel(id) );
622  }
623 
624  void clear() {
625  ladder.clear();
626  blade.clear();
627  panel.clear();
628  }
629 
630  private:
631  std::vector<unsigned short> ladder;
632  std::vector<unsigned short> blade;
633  std::vector<unsigned short> panel;
634  };
635 
637  public:
639 
640  void book(const std::string& prefix, TTree *tree) {
641  BOOK(order);
642  BOOK(ring);
643  BOOK(rod);
644  }
645 
646  void push_back(const TrackerTopology& tTopo, const DetId& id) {
647  const auto parsed = parse(tTopo, id);
648  order .push_back(parsed.order );
649  ring .push_back(parsed.ring );
650  rod .push_back(parsed.rod );
651  }
652 
653  void resize(size_t size) {
654  order.resize(size);
655  ring.resize(size);
656  rod.resize(size);
657  }
658 
659  void set(size_t index, const TrackerTopology& tTopo, const DetId& id) {
660  const auto parsed = parse(tTopo, id);
661  order [index] = parsed.order ;
662  ring [index] = parsed.ring ;
663  rod [index] = parsed.rod ;
664  }
665 
666  void clear() {
667  order.clear();
668  ring.clear();
669  rod.clear();
670  }
671 
672  private:
673  struct Parsed {
674  // use int here instead of short to avoid compilation errors due
675  // to narrowing conversion (less boilerplate than explicit static_casts)
676  unsigned int order = 0;
677  unsigned int ring = 0;
678  unsigned int rod = 0;
679  };
680  Parsed parse(const TrackerTopology& tTopo, const DetId& id) const {
681  switch(id.subdetId()) {
683  return Parsed{tTopo.tibOrder(id), 0, 0};
685  return Parsed{tTopo.tidOrder(id), tTopo.tidRing(id), 0};
687  return Parsed{0, 0, tTopo.tobRod(id)};
689  return Parsed{tTopo.tecOrder(id), tTopo.tecRing(id), 0};
690  default:
691  return Parsed{};
692  };
693  }
694 
695  std::vector<unsigned short> order;
696  std::vector<unsigned short> ring;
697  std::vector<unsigned short> rod;
698  };
699 
701  public:
703 
704  void book(const std::string& prefix, TTree *tree) {
705  BOOK(string);
706  BOOK(petalNumber);
707  BOOK(isStereo);
708  BOOK(isRPhi);
709  BOOK(isGlued);
710  }
711 
712  void push_back(const TrackerTopology& tTopo, const DetId& id) {
713  const auto parsed = parse(tTopo, id);
714  string .push_back(parsed.string );
715  petalNumber.push_back(parsed.petalNumber);
716  isStereo .push_back(tTopo.isStereo(id));
717  isRPhi .push_back(tTopo.isRPhi(id));
718  isGlued .push_back(parsed.glued);
719  }
720 
721  void resize(size_t size) {
722  string .resize(size);
723  petalNumber.resize(size);
724  isStereo .resize(size);
725  isRPhi .resize(size);
726  isGlued .resize(size);
727  }
728 
729  void set(size_t index, const TrackerTopology& tTopo, const DetId& id) {
730  const auto parsed = parse(tTopo, id);
731  string [index] = parsed.string ;
732  petalNumber[index] = parsed.petalNumber;
733  isStereo [index] = tTopo.isStereo(id);
734  isRPhi [index] = tTopo.isRPhi(id);
735  isGlued [index] = parsed.glued;
736  }
737 
738  void clear() {
739  string.clear();
740  isStereo.clear();
741  isRPhi.clear();
742  isGlued.clear();
743  petalNumber.clear();
744  }
745 
746  private:
747  struct Parsed {
748  // use int here instead of short to avoid compilation errors due
749  // to narrowing conversion (less boilerplate than explicit static_casts)
750  unsigned int string = 0;
751  unsigned int petalNumber = 0;
752  bool glued = false;
753  };
754  Parsed parse(const TrackerTopology& tTopo, const DetId& id) const {
755  switch(id.subdetId()) {
757  return Parsed{tTopo.tibString(id), 0, tTopo.tibIsDoubleSide(id)};
759  return Parsed{0, 0, tTopo.tidIsDoubleSide(id)};
761  return Parsed{0, 0, tTopo.tobIsDoubleSide(id)};
763  return Parsed{0, tTopo.tecPetalNumber(id), tTopo.tecIsDoubleSide(id)};
764  default:
765  return Parsed{};
766  }
767  }
768 
769  std::vector<unsigned short> string;
770  std::vector<unsigned short> petalNumber;
771  std::vector<unsigned short> isStereo;
772  std::vector<unsigned short> isRPhi;
773  std::vector<unsigned short> isGlued;
774  };
775 
777  public:
779 
780  void book(const std::string& prefix, TTree *tree) {
781  BOOK(isLower);
782  BOOK(isUpper);
783  BOOK(isStack);
784  }
785 
786  void push_back(const TrackerTopology& tTopo, const DetId& id) {
787  isLower.push_back(tTopo.isLower(id));
788  isUpper.push_back(tTopo.isUpper(id));
789  isStack.push_back(tTopo.stack(id) == 0); // equivalent to *IsDoubleSide() but without the hardcoded layer+ring requirements
790  }
791 
792  void clear() {
793  isLower.clear();
794  isUpper.clear();
795  isStack.clear();
796  }
797 
798  private:
799  std::vector<unsigned short> isLower;
800  std::vector<unsigned short> isUpper;
801  std::vector<unsigned short> isStack;
802  };
803 #undef BOOK
804 
805  using DetIdPixel = CombineDetId<DetIdCommon, DetIdPixelOnly>;
806  using DetIdStrip = CombineDetId<DetIdCommon, DetIdOTCommon, DetIdStripOnly>;
807  using DetIdPhase2OT = CombineDetId<DetIdCommon, DetIdOTCommon, DetIdPhase2OTOnly>;
808  using DetIdAll = CombineDetId<DetIdCommon, DetIdPixelOnly, DetIdOTCommon, DetIdStripOnly>;
809  using DetIdAllPhase2 = CombineDetId<DetIdCommon, DetIdPixelOnly, DetIdOTCommon, DetIdPhase2OTOnly>;
810 
811  // event
815 
817  // tracks
818  // (first) index runs through tracks
819  std::vector<float> trk_px ;
820  std::vector<float> trk_py ;
821  std::vector<float> trk_pz ;
822  std::vector<float> trk_pt ;
823  std::vector<float> trk_inner_px ;
824  std::vector<float> trk_inner_py ;
825  std::vector<float> trk_inner_pz ;
826  std::vector<float> trk_inner_pt ;
827  std::vector<float> trk_outer_px ;
828  std::vector<float> trk_outer_py ;
829  std::vector<float> trk_outer_pz ;
830  std::vector<float> trk_outer_pt ;
831  std::vector<float> trk_eta ;
832  std::vector<float> trk_lambda ;
833  std::vector<float> trk_cotTheta ;
834  std::vector<float> trk_phi ;
835  std::vector<float> trk_dxy ;
836  std::vector<float> trk_dz ;
837  std::vector<float> trk_ptErr ;
838  std::vector<float> trk_etaErr ;
839  std::vector<float> trk_lambdaErr;
840  std::vector<float> trk_phiErr ;
841  std::vector<float> trk_dxyErr ;
842  std::vector<float> trk_dzErr ;
843  std::vector<float> trk_refpoint_x;
844  std::vector<float> trk_refpoint_y;
845  std::vector<float> trk_refpoint_z;
846  std::vector<float> trk_nChi2 ;
847  std::vector<int> trk_q ;
848  std::vector<unsigned int> trk_nValid ;
849  std::vector<unsigned int> trk_nInvalid;
850  std::vector<unsigned int> trk_nPixel ;
851  std::vector<unsigned int> trk_nStrip ;
852  std::vector<unsigned int> trk_nPixelLay;
853  std::vector<unsigned int> trk_nStripLay;
854  std::vector<unsigned int> trk_n3DLay ;
855  std::vector<unsigned int> trk_nOuterLost;
856  std::vector<unsigned int> trk_nInnerLost;
857  std::vector<unsigned int> trk_algo ;
858  std::vector<unsigned int> trk_originalAlgo;
859  std::vector<decltype(reco::TrackBase().algoMaskUL())> trk_algoMask;
860  std::vector<unsigned short> trk_stopReason;
861  std::vector<short> trk_isHP ;
862  std::vector<int> trk_seedIdx ;
863  std::vector<int> trk_vtxIdx;
864  std::vector<std::vector<float> > trk_shareFrac; // second index runs through matched TrackingParticles
865  std::vector<std::vector<int> > trk_simTrkIdx; // second index runs through matched TrackingParticles
866  std::vector<std::vector<int> > trk_hitIdx; // second index runs through hits
867  std::vector<std::vector<int> > trk_hitType; // second index runs through hits
869  // sim tracks
870  // (first) index runs through TrackingParticles
871  std::vector<int> sim_event ;
872  std::vector<int> sim_bunchCrossing;
873  std::vector<int> sim_pdgId ;
874  std::vector<std::vector<int> >sim_genPdgIds;
875  std::vector<int> sim_isFromBHadron;
876  std::vector<float> sim_px ;
877  std::vector<float> sim_py ;
878  std::vector<float> sim_pz ;
879  std::vector<float> sim_pt ;
880  std::vector<float> sim_eta ;
881  std::vector<float> sim_phi ;
882  std::vector<float> sim_pca_pt ;
883  std::vector<float> sim_pca_eta ;
884  std::vector<float> sim_pca_lambda;
885  std::vector<float> sim_pca_cotTheta;
886  std::vector<float> sim_pca_phi ;
887  std::vector<float> sim_pca_dxy ;
888  std::vector<float> sim_pca_dz ;
889  std::vector<int> sim_q ;
890  std::vector<unsigned int> sim_nValid ;
891  std::vector<unsigned int> sim_nPixel ;
892  std::vector<unsigned int> sim_nStrip ;
893  std::vector<unsigned int> sim_nLay;
894  std::vector<unsigned int> sim_nPixelLay;
895  std::vector<unsigned int> sim_n3DLay ;
896  std::vector<std::vector<int> > sim_trkIdx; // second index runs through matched tracks
897  std::vector<std::vector<float> > sim_shareFrac; // second index runs through matched tracks
898  std::vector<std::vector<int> > sim_seedIdx; // second index runs through matched seeds
899  std::vector<int> sim_parentVtxIdx;
900  std::vector<std::vector<int> > sim_decayVtxIdx; // second index runs through decay vertices
901  std::vector<std::vector<int> > sim_simHitIdx; // second index runs through SimHits
903  // pixel hits
904  // (first) index runs through hits
905  std::vector<short> pix_isBarrel ;
907  std::vector<std::vector<int> > pix_trkIdx; // second index runs through tracks containing this hit
908  std::vector<std::vector<int> > pix_seeIdx; // second index runs through seeds containing this hit
909  std::vector<std::vector<int> > pix_simHitIdx; // second index runs through SimHits inducing this hit
910  std::vector<std::vector<float> > pix_chargeFraction; // second index runs through SimHits inducing this hit
911  std::vector<unsigned short> pix_simType;
912  std::vector<float> pix_x ;
913  std::vector<float> pix_y ;
914  std::vector<float> pix_z ;
915  std::vector<float> pix_xx ;
916  std::vector<float> pix_xy ;
917  std::vector<float> pix_yy ;
918  std::vector<float> pix_yz ;
919  std::vector<float> pix_zz ;
920  std::vector<float> pix_zx ;
921  std::vector<float> pix_radL ; //http://cmslxr.fnal.gov/lxr/source/DataFormats/GeometrySurface/interface/MediumProperties.h
922  std::vector<float> pix_bbxi ;
924  // strip hits
925  // (first) index runs through hits
926  std::vector<short> str_isBarrel ;
928  std::vector<std::vector<int> > str_trkIdx; // second index runs through tracks containing this hit
929  std::vector<std::vector<int> > str_seeIdx; // second index runs through seeds containing this hit
930  std::vector<std::vector<int> > str_simHitIdx; // second index runs through SimHits inducing this hit
931  std::vector<std::vector<float> > str_chargeFraction; // second index runs through SimHits inducing this hit
932  std::vector<unsigned short> str_simType;
933  std::vector<float> str_x ;
934  std::vector<float> str_y ;
935  std::vector<float> str_z ;
936  std::vector<float> str_xx ;
937  std::vector<float> str_xy ;
938  std::vector<float> str_yy ;
939  std::vector<float> str_yz ;
940  std::vector<float> str_zz ;
941  std::vector<float> str_zx ;
942  std::vector<float> str_radL ; //http://cmslxr.fnal.gov/lxr/source/DataFormats/GeometrySurface/interface/MediumProperties.h
943  std::vector<float> str_bbxi ;
945  // strip matched hits
946  // (first) index runs through hits
947  std::vector<short> glu_isBarrel ;
949  std::vector<int> glu_monoIdx ;
950  std::vector<int> glu_stereoIdx;
951  std::vector<std::vector<int> > glu_seeIdx; // second index runs through seeds containing this hit
952  std::vector<float> glu_x ;
953  std::vector<float> glu_y ;
954  std::vector<float> glu_z ;
955  std::vector<float> glu_xx ;
956  std::vector<float> glu_xy ;
957  std::vector<float> glu_yy ;
958  std::vector<float> glu_yz ;
959  std::vector<float> glu_zz ;
960  std::vector<float> glu_zx ;
961  std::vector<float> glu_radL ; //http://cmslxr.fnal.gov/lxr/source/DataFormats/GeometrySurface/interface/MediumProperties.h
962  std::vector<float> glu_bbxi ;
964  // phase2 Outer Tracker hits
965  // (first) index runs through hits
966  std::vector<short> ph2_isBarrel ;
968  std::vector<std::vector<int> > ph2_trkIdx; // second index runs through tracks containing this hit
969  std::vector<std::vector<int> > ph2_seeIdx; // second index runs through seeds containing this hit
970  std::vector<std::vector<int> > ph2_simHitIdx; // second index runs through SimHits inducing this hit
971  //std::vector<std::vector<float> > ph2_chargeFraction; // Not supported at the moment for Phase2
972  std::vector<unsigned short> ph2_simType;
973  std::vector<float> ph2_x ;
974  std::vector<float> ph2_y ;
975  std::vector<float> ph2_z ;
976  std::vector<float> ph2_xx ;
977  std::vector<float> ph2_xy ;
978  std::vector<float> ph2_yy ;
979  std::vector<float> ph2_yz ;
980  std::vector<float> ph2_zz ;
981  std::vector<float> ph2_zx ;
982  std::vector<float> ph2_radL ; //http://cmslxr.fnal.gov/lxr/source/DataFormats/GeometrySurface/interface/MediumProperties.h
983  std::vector<float> ph2_bbxi ;
984 
986  // invalid (missing/inactive/etc) hits
987  // (first) index runs through hits
988  std::vector<short> inv_isBarrel;
991  std::vector<unsigned short> inv_type;
993  // sim hits
994  // (first) index runs through hits
997  std::vector<float> simhit_x;
998  std::vector<float> simhit_y;
999  std::vector<float> simhit_z;
1000  std::vector<int> simhit_particle;
1001  std::vector<short> simhit_process;
1002  std::vector<float> simhit_eloss;
1003  std::vector<float> simhit_tof;
1004  //std::vector<unsigned int> simhit_simTrackId; // can be useful for debugging, but not much of general interest
1005  std::vector<int> simhit_simTrkIdx;
1006  std::vector<std::vector<int> > simhit_hitIdx; // second index runs through induced reco hits
1007  std::vector<std::vector<int> > simhit_hitType; // second index runs through induced reco hits
1009  // beam spot
1010  float bsp_x;
1011  float bsp_y;
1012  float bsp_z;
1013  float bsp_sigmax;
1014  float bsp_sigmay;
1015  float bsp_sigmaz;
1017  // seeds
1018  // (first) index runs through seeds
1019  std::vector<short> see_fitok ;
1020  std::vector<float> see_px ;
1021  std::vector<float> see_py ;
1022  std::vector<float> see_pz ;
1023  std::vector<float> see_pt ;
1024  std::vector<float> see_eta ;
1025  std::vector<float> see_phi ;
1026  std::vector<float> see_dxy ;
1027  std::vector<float> see_dz ;
1028  std::vector<float> see_ptErr ;
1029  std::vector<float> see_etaErr ;
1030  std::vector<float> see_phiErr ;
1031  std::vector<float> see_dxyErr ;
1032  std::vector<float> see_dzErr ;
1033  std::vector<float> see_chi2 ;
1034  std::vector<float> see_statePt;
1035  std::vector<float> see_stateTrajX;
1036  std::vector<float> see_stateTrajY;
1037  std::vector<float> see_stateTrajPx;
1038  std::vector<float> see_stateTrajPy;
1039  std::vector<float> see_stateTrajPz;
1040  std::vector<int> see_q ;
1041  std::vector<unsigned int> see_nValid ;
1042  std::vector<unsigned int> see_nPixel ;
1043  std::vector<unsigned int> see_nGlued ;
1044  std::vector<unsigned int> see_nStrip ;
1045  std::vector<unsigned int> see_nPhase2OT;
1046  std::vector<unsigned int> see_algo ;
1047  std::vector<unsigned short> see_stopReason;
1048  std::vector<int> see_trkIdx;
1049  std::vector<std::vector<float> > see_shareFrac; // second index runs through matched TrackingParticles
1050  std::vector<std::vector<int> > see_simTrkIdx; // second index runs through matched TrackingParticles
1051  std::vector<std::vector<int> > see_hitIdx; // second index runs through hits
1052  std::vector<std::vector<int> > see_hitType; // second index runs through hits
1053  //seed algo offset, index runs through iterations
1054  std::vector<unsigned int> see_offset ;
1055 
1056 
1058  // Vertices
1059  // (first) index runs through vertices
1060  std::vector<float> vtx_x;
1061  std::vector<float> vtx_y;
1062  std::vector<float> vtx_z;
1063  std::vector<float> vtx_xErr;
1064  std::vector<float> vtx_yErr;
1065  std::vector<float> vtx_zErr;
1066  std::vector<float> vtx_ndof;
1067  std::vector<float> vtx_chi2;
1068  std::vector<short> vtx_fake;
1069  std::vector<short> vtx_valid;
1070  std::vector<std::vector<int> > vtx_trkIdx; // second index runs through tracks used in the vertex fit
1071 
1073  // Tracking vertices
1074  // (first) index runs through TrackingVertices
1075  std::vector<int> simvtx_event;
1076  std::vector<int> simvtx_bunchCrossing;
1077  std::vector<unsigned int> simvtx_processType; // only from first SimVertex of TrackingVertex
1078  std::vector<float> simvtx_x;
1079  std::vector<float> simvtx_y;
1080  std::vector<float> simvtx_z;
1081  std::vector<std::vector<int> > simvtx_sourceSimIdx; // second index runs through source TrackingParticles
1082  std::vector<std::vector<int> > simvtx_daughterSimIdx; // second index runs through daughter TrackingParticles
1083  std::vector<int> simpv_idx;
1084 };
1085 
1086 //
1087 // constructors and destructor
1088 //
1090  trackToken_(consumes<edm::View<reco::Track> >(iConfig.getUntrackedParameter<edm::InputTag>("tracks"))),
1091  clusterTPMapToken_(consumes<ClusterTPAssociation>(iConfig.getUntrackedParameter<edm::InputTag>("clusterTPMap"))),
1092  simHitTPMapToken_(consumes<SimHitTPAssociationProducer::SimHitTPAssociationList>(iConfig.getUntrackedParameter<edm::InputTag>("simHitTPMap"))),
1093  trackAssociatorToken_(consumes<reco::TrackToTrackingParticleAssociator>(iConfig.getUntrackedParameter<edm::InputTag>("trackAssociator"))),
1094  pixelSimLinkToken_(consumes<edm::DetSetVector<PixelDigiSimLink> >(iConfig.getUntrackedParameter<edm::InputTag>("pixelDigiSimLink"))),
1095  stripSimLinkToken_(consumes<edm::DetSetVector<StripDigiSimLink> >(iConfig.getUntrackedParameter<edm::InputTag>("stripDigiSimLink"))),
1096  siphase2OTSimLinksToken_(consumes<edm::DetSetVector<PixelDigiSimLink> >(iConfig.getUntrackedParameter<edm::InputTag>("phase2OTSimLink"))),
1097  includeStripHits_(iConfig.getUntrackedParameter<edm::InputTag>("stripDigiSimLink").label() != ""),
1098  includePhase2OTHits_(iConfig.getUntrackedParameter<edm::InputTag>("phase2OTSimLink").label() != ""),
1099  beamSpotToken_(consumes<reco::BeamSpot>(iConfig.getUntrackedParameter<edm::InputTag>("beamSpot"))),
1100  pixelRecHitToken_(consumes<SiPixelRecHitCollection>(iConfig.getUntrackedParameter<edm::InputTag>("pixelRecHits"))),
1101  stripRphiRecHitToken_(consumes<SiStripRecHit2DCollection>(iConfig.getUntrackedParameter<edm::InputTag>("stripRphiRecHits"))),
1102  stripStereoRecHitToken_(consumes<SiStripRecHit2DCollection>(iConfig.getUntrackedParameter<edm::InputTag>("stripStereoRecHits"))),
1103  stripMatchedRecHitToken_(consumes<SiStripMatchedRecHit2DCollection>(iConfig.getUntrackedParameter<edm::InputTag>("stripMatchedRecHits"))),
1104  phase2OTRecHitToken_(consumes<Phase2TrackerRecHit1DCollectionNew>(iConfig.getUntrackedParameter<edm::InputTag>("phase2OTRecHits"))),
1105  vertexToken_(consumes<reco::VertexCollection>(iConfig.getUntrackedParameter<edm::InputTag>("vertices"))),
1106  trackingVertexToken_(consumes<TrackingVertexCollection>(iConfig.getUntrackedParameter<edm::InputTag>("trackingVertices"))),
1107  tpNLayersToken_(consumes<edm::ValueMap<unsigned int> >(iConfig.getUntrackedParameter<edm::InputTag>("trackingParticleNlayers"))),
1108  tpNPixelLayersToken_(consumes<edm::ValueMap<unsigned int> >(iConfig.getUntrackedParameter<edm::InputTag>("trackingParticleNpixellayers"))),
1109  tpNStripStereoLayersToken_(consumes<edm::ValueMap<unsigned int> >(iConfig.getUntrackedParameter<edm::InputTag>("trackingParticleNstripstereolayers"))),
1110  builderName_(iConfig.getUntrackedParameter<std::string>("TTRHBuilder")),
1111  parametersDefinerName_(iConfig.getUntrackedParameter<std::string>("parametersDefiner")),
1112  includeSeeds_(iConfig.getUntrackedParameter<bool>("includeSeeds")),
1113  includeAllHits_(iConfig.getUntrackedParameter<bool>("includeAllHits"))
1114 {
1115  if(includeSeeds_) {
1116  seedTokens_ = edm::vector_transform(iConfig.getUntrackedParameter<std::vector<edm::InputTag> >("seedTracks"), [&](const edm::InputTag& tag) {
1117  return consumes<edm::View<reco::Track> >(tag);
1118  });
1119  seedStopReasonTokens_ = edm::vector_transform(iConfig.getUntrackedParameter<std::vector<edm::InputTag> >("trackCandidates"), [&](const edm::InputTag& tag) {
1120  return consumes<std::vector<short> >(tag);
1121  });
1122  if(seedTokens_.size() != seedStopReasonTokens_.size()) {
1123  throw cms::Exception("Configuration") << "Got " << seedTokens_.size() << " seed collections, but " << seedStopReasonTokens_.size() << " track candidate collections";
1124  }
1125  }
1126 
1127  if(includeAllHits_) {
1128  if(includeStripHits_ && includePhase2OTHits_) {
1129  throw cms::Exception("Configuration") << "Both stripDigiSimLink and phase2OTSimLink are set, please set only either one (this information is used to infer if you're running phase0/1 or phase2 detector)";
1130  }
1131  if(!includeStripHits_ && !includePhase2OTHits_) {
1132  throw cms::Exception("Configuration") << "Neither stripDigiSimLink or phase2OTSimLink are set, please set either one.";
1133  }
1134  }
1135 
1136  const bool tpRef = iConfig.getUntrackedParameter<bool>("trackingParticlesRef");
1137  const auto tpTag = iConfig.getUntrackedParameter<edm::InputTag>("trackingParticles");
1138  if(tpRef) {
1139  trackingParticleRefToken_ = consumes<TrackingParticleRefVector>(tpTag);
1140  }
1141  else {
1142  trackingParticleToken_ = consumes<TrackingParticleCollection>(tpTag);
1143  }
1144 
1145  tracer_.depth(-2); // as in SimTracker/TrackHistory/src/TrackClassifier.cc
1146 
1147  usesResource(TFileService::kSharedResource);
1149  t = fs->make<TTree>("tree","tree");
1150 
1151  t->Branch("event" , &ev_event);
1152  t->Branch("lumi" , &ev_lumi);
1153  t->Branch("run" , &ev_run);
1154 
1155  //tracks
1156  t->Branch("trk_px" , &trk_px);
1157  t->Branch("trk_py" , &trk_py);
1158  t->Branch("trk_pz" , &trk_pz);
1159  t->Branch("trk_pt" , &trk_pt);
1160  t->Branch("trk_inner_px" , &trk_inner_px);
1161  t->Branch("trk_inner_py" , &trk_inner_py);
1162  t->Branch("trk_inner_pz" , &trk_inner_pz);
1163  t->Branch("trk_inner_pt" , &trk_inner_pt);
1164  t->Branch("trk_outer_px" , &trk_outer_px);
1165  t->Branch("trk_outer_py" , &trk_outer_py);
1166  t->Branch("trk_outer_pz" , &trk_outer_pz);
1167  t->Branch("trk_outer_pt" , &trk_outer_pt);
1168  t->Branch("trk_eta" , &trk_eta);
1169  t->Branch("trk_lambda" , &trk_lambda);
1170  t->Branch("trk_cotTheta" , &trk_cotTheta);
1171  t->Branch("trk_phi" , &trk_phi);
1172  t->Branch("trk_dxy" , &trk_dxy );
1173  t->Branch("trk_dz" , &trk_dz );
1174  t->Branch("trk_ptErr" , &trk_ptErr );
1175  t->Branch("trk_etaErr" , &trk_etaErr );
1176  t->Branch("trk_lambdaErr", &trk_lambdaErr);
1177  t->Branch("trk_phiErr" , &trk_phiErr );
1178  t->Branch("trk_dxyErr" , &trk_dxyErr );
1179  t->Branch("trk_dzErr" , &trk_dzErr );
1180  t->Branch("trk_refpoint_x", &trk_refpoint_x);
1181  t->Branch("trk_refpoint_y", &trk_refpoint_y);
1182  t->Branch("trk_refpoint_z", &trk_refpoint_z);
1183  t->Branch("trk_nChi2" , &trk_nChi2);
1184  t->Branch("trk_q" , &trk_q);
1185  t->Branch("trk_nValid" , &trk_nValid );
1186  t->Branch("trk_nInvalid" , &trk_nInvalid);
1187  t->Branch("trk_nPixel" , &trk_nPixel );
1188  t->Branch("trk_nStrip" , &trk_nStrip );
1189  t->Branch("trk_nPixelLay", &trk_nPixelLay);
1190  t->Branch("trk_nStripLay", &trk_nStripLay);
1191  t->Branch("trk_n3DLay" , &trk_n3DLay );
1192  t->Branch("trk_nOuterLost", &trk_nOuterLost );
1193  t->Branch("trk_nInnerLost", &trk_nInnerLost );
1194  t->Branch("trk_algo" , &trk_algo );
1195  t->Branch("trk_originalAlgo", &trk_originalAlgo);
1196  t->Branch("trk_algoMask" , &trk_algoMask);
1197  t->Branch("trk_stopReason", &trk_stopReason);
1198  t->Branch("trk_isHP" , &trk_isHP );
1199  if(includeSeeds_) {
1200  t->Branch("trk_seedIdx" , &trk_seedIdx );
1201  }
1202  t->Branch("trk_vtxIdx" , &trk_vtxIdx);
1203  t->Branch("trk_shareFrac", &trk_shareFrac);
1204  t->Branch("trk_simTrkIdx", &trk_simTrkIdx );
1205  if(includeAllHits_) {
1206  t->Branch("trk_hitIdx" , &trk_hitIdx);
1207  t->Branch("trk_hitType", &trk_hitType);
1208  }
1209  //sim tracks
1210  t->Branch("sim_event" , &sim_event );
1211  t->Branch("sim_bunchCrossing", &sim_bunchCrossing);
1212  t->Branch("sim_pdgId" , &sim_pdgId );
1213  t->Branch("sim_genPdgIds", &sim_genPdgIds);
1214  t->Branch("sim_isFromBHadron", &sim_isFromBHadron);
1215  t->Branch("sim_px" , &sim_px );
1216  t->Branch("sim_py" , &sim_py );
1217  t->Branch("sim_pz" , &sim_pz );
1218  t->Branch("sim_pt" , &sim_pt );
1219  t->Branch("sim_eta" , &sim_eta );
1220  t->Branch("sim_phi" , &sim_phi );
1221  t->Branch("sim_pca_pt" , &sim_pca_pt );
1222  t->Branch("sim_pca_eta" , &sim_pca_eta );
1223  t->Branch("sim_pca_lambda", &sim_pca_lambda);
1224  t->Branch("sim_pca_cotTheta", &sim_pca_cotTheta);
1225  t->Branch("sim_pca_phi" , &sim_pca_phi );
1226  t->Branch("sim_pca_dxy" , &sim_pca_dxy );
1227  t->Branch("sim_pca_dz" , &sim_pca_dz );
1228  t->Branch("sim_q" , &sim_q );
1229  t->Branch("sim_nValid" , &sim_nValid );
1230  t->Branch("sim_nPixel" , &sim_nPixel );
1231  t->Branch("sim_nStrip" , &sim_nStrip );
1232  t->Branch("sim_nLay" , &sim_nLay );
1233  t->Branch("sim_nPixelLay", &sim_nPixelLay);
1234  t->Branch("sim_n3DLay" , &sim_n3DLay );
1235  t->Branch("sim_trkIdx" , &sim_trkIdx );
1236  t->Branch("sim_shareFrac", &sim_shareFrac);
1237  if(includeSeeds_) {
1238  t->Branch("sim_seedIdx" , &sim_seedIdx );
1239  }
1240  t->Branch("sim_parentVtxIdx", &sim_parentVtxIdx);
1241  t->Branch("sim_decayVtxIdx", &sim_decayVtxIdx);
1242  if(includeAllHits_) {
1243  t->Branch("sim_simHitIdx" , &sim_simHitIdx );
1244  }
1245  if(includeAllHits_) {
1246  //pixels
1247  t->Branch("pix_isBarrel" , &pix_isBarrel );
1248  pix_detId.book("pix", t);
1249  t->Branch("pix_trkIdx" , &pix_trkIdx );
1250  if(includeSeeds_) {
1251  t->Branch("pix_seeIdx" , &pix_seeIdx );
1252  }
1253  t->Branch("pix_simHitIdx" , &pix_simHitIdx);
1254  t->Branch("pix_chargeFraction", &pix_chargeFraction);
1255  t->Branch("pix_simType", &pix_simType);
1256  t->Branch("pix_x" , &pix_x );
1257  t->Branch("pix_y" , &pix_y );
1258  t->Branch("pix_z" , &pix_z );
1259  t->Branch("pix_xx" , &pix_xx );
1260  t->Branch("pix_xy" , &pix_xy );
1261  t->Branch("pix_yy" , &pix_yy );
1262  t->Branch("pix_yz" , &pix_yz );
1263  t->Branch("pix_zz" , &pix_zz );
1264  t->Branch("pix_zx" , &pix_zx );
1265  t->Branch("pix_radL" , &pix_radL );
1266  t->Branch("pix_bbxi" , &pix_bbxi );
1267  t->Branch("pix_bbxi" , &pix_bbxi );
1268  //strips
1269  if(includeStripHits_){
1270  t->Branch("str_isBarrel" , &str_isBarrel );
1271  str_detId.book("str", t);
1272  t->Branch("str_trkIdx" , &str_trkIdx );
1273  if(includeSeeds_) {
1274  t->Branch("str_seeIdx" , &str_seeIdx );
1275  }
1276  t->Branch("str_simHitIdx" , &str_simHitIdx);
1277  t->Branch("str_chargeFraction", &str_chargeFraction);
1278  t->Branch("str_simType", &str_simType);
1279  t->Branch("str_x" , &str_x );
1280  t->Branch("str_y" , &str_y );
1281  t->Branch("str_z" , &str_z );
1282  t->Branch("str_xx" , &str_xx );
1283  t->Branch("str_xy" , &str_xy );
1284  t->Branch("str_yy" , &str_yy );
1285  t->Branch("str_yz" , &str_yz );
1286  t->Branch("str_zz" , &str_zz );
1287  t->Branch("str_zx" , &str_zx );
1288  t->Branch("str_radL" , &str_radL );
1289  t->Branch("str_bbxi" , &str_bbxi );
1290  //matched hits
1291  t->Branch("glu_isBarrel" , &glu_isBarrel );
1292  glu_detId.book("glu", t);
1293  t->Branch("glu_monoIdx" , &glu_monoIdx );
1294  t->Branch("glu_stereoIdx" , &glu_stereoIdx);
1295  if(includeSeeds_) {
1296  t->Branch("glu_seeIdx" , &glu_seeIdx );
1297  }
1298  t->Branch("glu_x" , &glu_x );
1299  t->Branch("glu_y" , &glu_y );
1300  t->Branch("glu_z" , &glu_z );
1301  t->Branch("glu_xx" , &glu_xx );
1302  t->Branch("glu_xy" , &glu_xy );
1303  t->Branch("glu_yy" , &glu_yy );
1304  t->Branch("glu_yz" , &glu_yz );
1305  t->Branch("glu_zz" , &glu_zz );
1306  t->Branch("glu_zx" , &glu_zx );
1307  t->Branch("glu_radL" , &glu_radL );
1308  t->Branch("glu_bbxi" , &glu_bbxi );
1309  }
1310  //phase2 OT
1311  if(includePhase2OTHits_){
1312  t->Branch("ph2_isBarrel" , &ph2_isBarrel );
1313  ph2_detId.book("ph2", t);
1314  t->Branch("ph2_trkIdx" , &ph2_trkIdx );
1315  if(includeSeeds_) {
1316  t->Branch("ph2_seeIdx" , &ph2_seeIdx );
1317  }
1318  t->Branch("ph2_simHitIdx" , &ph2_simHitIdx);
1319  t->Branch("ph2_simType", &ph2_simType);
1320  t->Branch("ph2_x" , &ph2_x );
1321  t->Branch("ph2_y" , &ph2_y );
1322  t->Branch("ph2_z" , &ph2_z );
1323  t->Branch("ph2_xx" , &ph2_xx );
1324  t->Branch("ph2_xy" , &ph2_xy );
1325  t->Branch("ph2_yy" , &ph2_yy );
1326  t->Branch("ph2_yz" , &ph2_yz );
1327  t->Branch("ph2_zz" , &ph2_zz );
1328  t->Branch("ph2_zx" , &ph2_zx );
1329  t->Branch("ph2_radL" , &ph2_radL );
1330  t->Branch("ph2_bbxi" , &ph2_bbxi );
1331  t->Branch("ph2_bbxi" , &ph2_bbxi );
1332  }
1333  //invalid hits
1334  t->Branch("inv_isBarrel" , &inv_isBarrel );
1335  if(includeStripHits_) inv_detId.book("inv", t);
1336  else inv_detId_phase2.book("inv", t);
1337  t->Branch("inv_type" , &inv_type );
1338  //simhits
1339  if(includeStripHits_) simhit_detId.book("simhit", t);
1340  else simhit_detId_phase2.book("simhit", t);
1341  t->Branch("simhit_x" , &simhit_x);
1342  t->Branch("simhit_y" , &simhit_y);
1343  t->Branch("simhit_z" , &simhit_z);
1344  t->Branch("simhit_particle", &simhit_particle);
1345  t->Branch("simhit_process" , &simhit_process);
1346  t->Branch("simhit_eloss" , &simhit_eloss);
1347  t->Branch("simhit_tof" , &simhit_tof);
1348  //t->Branch("simhit_simTrackId", &simhit_simTrackId);
1349  t->Branch("simhit_simTrkIdx", &simhit_simTrkIdx);
1350  t->Branch("simhit_hitIdx" , &simhit_hitIdx);
1351  t->Branch("simhit_hitType" , &simhit_hitType);
1352  }
1353  //beam spot
1354  t->Branch("bsp_x" , &bsp_x , "bsp_x/F");
1355  t->Branch("bsp_y" , &bsp_y , "bsp_y/F");
1356  t->Branch("bsp_z" , &bsp_z , "bsp_z/F");
1357  t->Branch("bsp_sigmax" , &bsp_sigmax , "bsp_sigmax/F");
1358  t->Branch("bsp_sigmay" , &bsp_sigmay , "bsp_sigmay/F");
1359  t->Branch("bsp_sigmaz" , &bsp_sigmaz , "bsp_sigmaz/F");
1360  if(includeSeeds_) {
1361  //seeds
1362  t->Branch("see_fitok" , &see_fitok );
1363  t->Branch("see_px" , &see_px );
1364  t->Branch("see_py" , &see_py );
1365  t->Branch("see_pz" , &see_pz );
1366  t->Branch("see_pt" , &see_pt );
1367  t->Branch("see_eta" , &see_eta );
1368  t->Branch("see_phi" , &see_phi );
1369  t->Branch("see_dxy" , &see_dxy );
1370  t->Branch("see_dz" , &see_dz );
1371  t->Branch("see_ptErr" , &see_ptErr );
1372  t->Branch("see_etaErr" , &see_etaErr );
1373  t->Branch("see_phiErr" , &see_phiErr );
1374  t->Branch("see_dxyErr" , &see_dxyErr );
1375  t->Branch("see_dzErr" , &see_dzErr );
1376  t->Branch("see_chi2" , &see_chi2 );
1377  t->Branch("see_statePt" , &see_statePt );
1378  t->Branch("see_stateTrajX", &see_stateTrajX);
1379  t->Branch("see_stateTrajY", &see_stateTrajY);
1380  t->Branch("see_stateTrajPx", &see_stateTrajPx);
1381  t->Branch("see_stateTrajPy", &see_stateTrajPy);
1382  t->Branch("see_stateTrajPz", &see_stateTrajPz);
1383  t->Branch("see_q" , &see_q );
1384  t->Branch("see_nValid" , &see_nValid );
1385  t->Branch("see_nPixel" , &see_nPixel );
1386  t->Branch("see_nGlued" , &see_nGlued );
1387  t->Branch("see_nStrip" , &see_nStrip );
1388  t->Branch("see_nPhase2OT", &see_nPhase2OT);
1389  t->Branch("see_algo" , &see_algo );
1390  t->Branch("see_stopReason", &see_stopReason);
1391  t->Branch("see_trkIdx" , &see_trkIdx );
1392  t->Branch("see_shareFrac", &see_shareFrac);
1393  t->Branch("see_simTrkIdx", &see_simTrkIdx );
1394  if(includeAllHits_) {
1395  t->Branch("see_hitIdx" , &see_hitIdx );
1396  t->Branch("see_hitType", &see_hitType );
1397  }
1398  //seed algo offset
1399  t->Branch("see_offset" , &see_offset );
1400  }
1401 
1402  //vertices
1403  t->Branch("vtx_x" , &vtx_x);
1404  t->Branch("vtx_y" , &vtx_y);
1405  t->Branch("vtx_z" , &vtx_z);
1406  t->Branch("vtx_xErr" , &vtx_xErr);
1407  t->Branch("vtx_yErr" , &vtx_yErr);
1408  t->Branch("vtx_zErr" , &vtx_zErr);
1409  t->Branch("vtx_ndof" , &vtx_ndof);
1410  t->Branch("vtx_chi2" , &vtx_chi2);
1411  t->Branch("vtx_fake" , &vtx_fake);
1412  t->Branch("vtx_valid" , &vtx_valid);
1413  t->Branch("vtx_trkIdx" , &vtx_trkIdx);
1414 
1415  // tracking vertices
1416  t->Branch("simvtx_event" , &simvtx_event );
1417  t->Branch("simvtx_bunchCrossing", &simvtx_bunchCrossing);
1418  t->Branch("simvtx_processType", &simvtx_processType);
1419  t->Branch("simvtx_x" , &simvtx_x);
1420  t->Branch("simvtx_y" , &simvtx_y);
1421  t->Branch("simvtx_z" , &simvtx_z);
1422  t->Branch("simvtx_sourceSimIdx", &simvtx_sourceSimIdx);
1423  t->Branch("simvtx_daughterSimIdx", &simvtx_daughterSimIdx);
1424 
1425  t->Branch("simpv_idx" , &simpv_idx);
1426 
1427  //t->Branch("" , &);
1428 }
1429 
1430 
1432  // do anything here that needs to be done at desctruction time
1433  // (e.g. close files, deallocate resources etc.)
1434 }
1435 
1436 
1437 //
1438 // member functions
1439 //
1441 
1442  ev_run = 0;
1443  ev_lumi = 0;
1444  ev_event = 0;
1445 
1446  //tracks
1447  trk_px .clear();
1448  trk_py .clear();
1449  trk_pz .clear();
1450  trk_pt .clear();
1451  trk_inner_px .clear();
1452  trk_inner_py .clear();
1453  trk_inner_pz .clear();
1454  trk_inner_pt .clear();
1455  trk_outer_px .clear();
1456  trk_outer_py .clear();
1457  trk_outer_pz .clear();
1458  trk_outer_pt .clear();
1459  trk_eta .clear();
1460  trk_lambda .clear();
1461  trk_cotTheta .clear();
1462  trk_phi .clear();
1463  trk_dxy .clear();
1464  trk_dz .clear();
1465  trk_ptErr .clear();
1466  trk_etaErr .clear();
1467  trk_lambdaErr.clear();
1468  trk_phiErr .clear();
1469  trk_dxyErr .clear();
1470  trk_dzErr .clear();
1471  trk_refpoint_x.clear();
1472  trk_refpoint_y.clear();
1473  trk_refpoint_z.clear();
1474  trk_nChi2 .clear();
1475  trk_q .clear();
1476  trk_nValid .clear();
1477  trk_nInvalid .clear();
1478  trk_nPixel .clear();
1479  trk_nStrip .clear();
1480  trk_nPixelLay.clear();
1481  trk_nStripLay.clear();
1482  trk_n3DLay .clear();
1483  trk_nOuterLost.clear();
1484  trk_nInnerLost.clear();
1485  trk_algo .clear();
1486  trk_originalAlgo.clear();
1487  trk_algoMask .clear();
1488  trk_stopReason.clear();
1489  trk_isHP .clear();
1490  trk_seedIdx .clear();
1491  trk_vtxIdx .clear();
1492  trk_shareFrac.clear();
1493  trk_simTrkIdx.clear();
1494  trk_hitIdx .clear();
1495  trk_hitType .clear();
1496  //sim tracks
1497  sim_event .clear();
1498  sim_bunchCrossing.clear();
1499  sim_pdgId .clear();
1500  sim_genPdgIds.clear();
1501  sim_isFromBHadron.clear();
1502  sim_px .clear();
1503  sim_py .clear();
1504  sim_pz .clear();
1505  sim_pt .clear();
1506  sim_eta .clear();
1507  sim_phi .clear();
1508  sim_pca_pt .clear();
1509  sim_pca_eta .clear();
1510  sim_pca_lambda.clear();
1511  sim_pca_cotTheta.clear();
1512  sim_pca_phi .clear();
1513  sim_pca_dxy .clear();
1514  sim_pca_dz .clear();
1515  sim_q .clear();
1516  sim_nValid .clear();
1517  sim_nPixel .clear();
1518  sim_nStrip .clear();
1519  sim_nLay .clear();
1520  sim_nPixelLay.clear();
1521  sim_n3DLay .clear();
1522  sim_trkIdx .clear();
1523  sim_seedIdx .clear();
1524  sim_shareFrac.clear();
1525  sim_parentVtxIdx.clear();
1526  sim_decayVtxIdx.clear();
1527  sim_simHitIdx .clear();
1528  //pixels
1529  pix_isBarrel .clear();
1530  pix_detId .clear();
1531  pix_trkIdx .clear();
1532  pix_seeIdx .clear();
1533  pix_simHitIdx.clear();
1534  pix_chargeFraction.clear();
1535  pix_simType.clear();
1536  pix_x .clear();
1537  pix_y .clear();
1538  pix_z .clear();
1539  pix_xx .clear();
1540  pix_xy .clear();
1541  pix_yy .clear();
1542  pix_yz .clear();
1543  pix_zz .clear();
1544  pix_zx .clear();
1545  pix_radL .clear();
1546  pix_bbxi .clear();
1547  //strips
1548  str_isBarrel .clear();
1549  str_detId .clear();
1550  str_trkIdx .clear();
1551  str_seeIdx .clear();
1552  str_simHitIdx.clear();
1553  str_chargeFraction.clear();
1554  str_simType.clear();
1555  str_x .clear();
1556  str_y .clear();
1557  str_z .clear();
1558  str_xx .clear();
1559  str_xy .clear();
1560  str_yy .clear();
1561  str_yz .clear();
1562  str_zz .clear();
1563  str_zx .clear();
1564  str_radL .clear();
1565  str_bbxi .clear();
1566  //matched hits
1567  glu_isBarrel .clear();
1568  glu_detId .clear();
1569  glu_monoIdx .clear();
1570  glu_stereoIdx.clear();
1571  glu_seeIdx .clear();
1572  glu_x .clear();
1573  glu_y .clear();
1574  glu_z .clear();
1575  glu_xx .clear();
1576  glu_xy .clear();
1577  glu_yy .clear();
1578  glu_yz .clear();
1579  glu_zz .clear();
1580  glu_zx .clear();
1581  glu_radL .clear();
1582  glu_bbxi .clear();
1583  //phase2 OT
1584  ph2_isBarrel .clear();
1585  ph2_detId .clear();
1586  ph2_trkIdx .clear();
1587  ph2_seeIdx .clear();
1588  ph2_simHitIdx.clear();
1589  ph2_simType.clear();
1590  ph2_x .clear();
1591  ph2_y .clear();
1592  ph2_z .clear();
1593  ph2_xx .clear();
1594  ph2_xy .clear();
1595  ph2_yy .clear();
1596  ph2_yz .clear();
1597  ph2_zz .clear();
1598  ph2_zx .clear();
1599  ph2_radL .clear();
1600  ph2_bbxi .clear();
1601  //invalid hits
1602  inv_isBarrel .clear();
1603  inv_detId .clear();
1604  inv_detId_phase2.clear();
1605  inv_type .clear();
1606  // simhits
1607  simhit_detId.clear();
1608  simhit_detId_phase2.clear();
1609  simhit_x.clear();
1610  simhit_y.clear();
1611  simhit_z.clear();
1612  simhit_particle.clear();
1613  simhit_process.clear();
1614  simhit_eloss.clear();
1615  simhit_tof.clear();
1616  //simhit_simTrackId.clear();
1617  simhit_simTrkIdx.clear();
1618  simhit_hitIdx.clear();
1619  simhit_hitType.clear();
1620  //beamspot
1621  bsp_x = -9999.;
1622  bsp_y = -9999.;
1623  bsp_z = -9999.;
1624  bsp_sigmax = -9999.;
1625  bsp_sigmay = -9999.;
1626  bsp_sigmaz = -9999.;
1627  //seeds
1628  see_fitok .clear();
1629  see_px .clear();
1630  see_py .clear();
1631  see_pz .clear();
1632  see_pt .clear();
1633  see_eta .clear();
1634  see_phi .clear();
1635  see_dxy .clear();
1636  see_dz .clear();
1637  see_ptErr .clear();
1638  see_etaErr .clear();
1639  see_phiErr .clear();
1640  see_dxyErr .clear();
1641  see_dzErr .clear();
1642  see_chi2 .clear();
1643  see_statePt.clear();
1644  see_stateTrajX.clear();
1645  see_stateTrajY.clear();
1646  see_stateTrajPx.clear();
1647  see_stateTrajPy.clear();
1648  see_stateTrajPz.clear();
1649  see_q .clear();
1650  see_nValid .clear();
1651  see_nPixel .clear();
1652  see_nGlued .clear();
1653  see_nStrip .clear();
1654  see_nPhase2OT.clear();
1655  see_algo .clear();
1656  see_stopReason.clear();
1657  see_trkIdx .clear();
1658  see_shareFrac.clear();
1659  see_simTrkIdx.clear();
1660  see_hitIdx .clear();
1661  see_hitType .clear();
1662  //seed algo offset
1663  see_offset.clear();
1664 
1665  // vertices
1666  vtx_x.clear();
1667  vtx_y.clear();
1668  vtx_z.clear();
1669  vtx_xErr.clear();
1670  vtx_yErr.clear();
1671  vtx_zErr.clear();
1672  vtx_ndof.clear();
1673  vtx_chi2.clear();
1674  vtx_fake.clear();
1675  vtx_valid.clear();
1676  vtx_trkIdx.clear();
1677 
1678  // Tracking vertices
1679  simvtx_event.clear();
1680  simvtx_bunchCrossing.clear();
1681  simvtx_x.clear();
1682  simvtx_y.clear();
1683  simvtx_z.clear();
1684  simvtx_sourceSimIdx.clear();
1685  simvtx_daughterSimIdx.clear();
1686  simpv_idx.clear();
1687 }
1688 
1689 
1690 // ------------ method called for each event ------------
1691 void TrackingNtuple::analyze(const edm::Event& iEvent, const edm::EventSetup& iSetup) {
1692 
1693  using namespace edm;
1694  using namespace reco;
1695  using namespace std;
1696 
1698  iSetup.get<IdealMagneticFieldRecord>().get(theMF);
1699 
1701  iSetup.get<TransientRecHitRecord>().get(builderName_,theTTRHBuilder);
1702 
1703  edm::ESHandle<TrackerTopology> tTopoHandle;
1704  iSetup.get<TrackerTopologyRcd>().get(tTopoHandle);
1705  const TrackerTopology& tTopo = *tTopoHandle;
1706 
1707  edm::ESHandle<TrackerGeometry> geometryHandle;
1708  iSetup.get<TrackerDigiGeometryRecord>().get(geometryHandle);
1709  const TrackerGeometry &tracker = *geometryHandle;
1710 
1712  iEvent.getByToken(trackAssociatorToken_, theAssociator);
1713  const reco::TrackToTrackingParticleAssociator& associatorByHits = *theAssociator;
1714 
1715  LogDebug("TrackingNtuple") << "Analyzing new event";
1716 
1717  //initialize tree variables
1718  clearVariables();
1719 
1720  // FIXME: we really need to move to edm::View for reading the
1721  // TrackingParticles... Unfortunately it has non-trivial
1722  // consequences on the associator/association interfaces etc.
1724  TrackingParticleRefKeySet tmpTPkeys;
1725  const TrackingParticleRefVector *tmpTPptr = nullptr;
1727  edm::Handle<TrackingParticleRefVector> TPCollectionHRefVector;
1728 
1729  if(!trackingParticleToken_.isUninitialized()) {
1730  iEvent.getByToken(trackingParticleToken_, TPCollectionH);
1731  for(size_t i=0, size=TPCollectionH->size(); i<size; ++i) {
1732  tmpTP.push_back(TrackingParticleRef(TPCollectionH, i));
1733  }
1734  tmpTPptr = &tmpTP;
1735  }
1736  else {
1737  iEvent.getByToken(trackingParticleRefToken_, TPCollectionHRefVector);
1738  tmpTPptr = TPCollectionHRefVector.product();
1739  for(const auto& ref: *tmpTPptr) {
1740  tmpTPkeys.insert(ref.key());
1741  }
1742  }
1743  const TrackingParticleRefVector& tpCollection = *tmpTPptr;
1744 
1745  // Fill mapping from Ref::key() to index
1746  TrackingParticleRefKeyToIndex tpKeyToIndex;
1747  for(size_t i=0; i<tpCollection.size(); ++i) {
1748  tpKeyToIndex[tpCollection[i].key()] = i;
1749  }
1750 
1751  // tracking vertices
1753  iEvent.getByToken(trackingVertexToken_, htv);
1754  const TrackingVertexCollection& tvs = *htv;
1755 
1756  // Fill mapping from Ref::key() to index
1757  TrackingVertexRefVector tvRefs;
1758  TrackingVertexRefKeyToIndex tvKeyToIndex;
1759  for(size_t i=0; i<tvs.size(); ++i) {
1760  const TrackingVertex& v = tvs[i];
1761  if(v.eventId().bunchCrossing() != 0) // Ignore OOTPU; would be better to not to hardcode?
1762  continue;
1763  tvKeyToIndex[i] = tvRefs.size();
1764  tvRefs.push_back(TrackingVertexRef(htv, i));
1765  }
1766 
1767  //get association maps, etc.
1768  Handle<ClusterTPAssociation> pCluster2TPListH;
1769  iEvent.getByToken(clusterTPMapToken_, pCluster2TPListH);
1770  const ClusterTPAssociation& clusterToTPMap = *pCluster2TPListH;
1772  iEvent.getByToken(simHitTPMapToken_, simHitsTPAssoc);
1773 
1774  // SimHit key -> index mapping
1775  SimHitRefKeyToIndex simHitRefKeyToIndex;
1776 
1777  //make a list to link TrackingParticles to its simhits
1778  std::vector<TPHitIndex> tpHitList;
1779 
1780  std::set<edm::ProductID> hitProductIds;
1781  std::map<edm::ProductID, size_t> seedCollToOffset;
1782 
1783  ev_run = iEvent.id().run();
1784  ev_lumi = iEvent.id().luminosityBlock();
1785  ev_event = iEvent.id().event();
1786 
1787  // Digi->Sim links for pixels and strips
1788  edm::Handle<edm::DetSetVector<PixelDigiSimLink> > pixelDigiSimLinksHandle;
1789  iEvent.getByToken(pixelSimLinkToken_, pixelDigiSimLinksHandle);
1790  const auto& pixelDigiSimLinks = *pixelDigiSimLinksHandle;
1791 
1792  edm::Handle<edm::DetSetVector<StripDigiSimLink> > stripDigiSimLinksHandle;
1793  iEvent.getByToken(stripSimLinkToken_, stripDigiSimLinksHandle);
1794 
1795  // Phase2 OT DigiSimLink
1796  edm::Handle<edm::DetSetVector<PixelDigiSimLink> > siphase2OTSimLinksHandle;
1797  iEvent.getByToken(siphase2OTSimLinksToken_, siphase2OTSimLinksHandle);
1798 
1799  //beamspot
1800  Handle<reco::BeamSpot> recoBeamSpotHandle;
1801  iEvent.getByToken(beamSpotToken_, recoBeamSpotHandle);
1802  BeamSpot const & bs = *recoBeamSpotHandle;
1803  fillBeamSpot(bs);
1804 
1805 
1806  //prapare list to link matched hits to collection
1807  vector<pair<int,int> > monoStereoClusterList;
1808  if(includeAllHits_) {
1809  // simhits
1810  fillSimHits(tracker, tpKeyToIndex, *simHitsTPAssoc, tTopo, simHitRefKeyToIndex, tpHitList);
1811 
1812  //pixel hits
1813  fillPixelHits(iEvent, clusterToTPMap, tpKeyToIndex, *simHitsTPAssoc, pixelDigiSimLinks, *theTTRHBuilder, tTopo, simHitRefKeyToIndex, hitProductIds);
1814 
1815  //strip hits
1816  if(includeStripHits_){
1817  LogDebug("TrackingNtuple") << "foundStripSimLink" ;
1818  const auto& stripDigiSimLinks = *stripDigiSimLinksHandle;
1819  fillStripRphiStereoHits(iEvent, clusterToTPMap, tpKeyToIndex, *simHitsTPAssoc, stripDigiSimLinks, *theTTRHBuilder, tTopo, simHitRefKeyToIndex, hitProductIds);
1820 
1821  //matched hits
1822  fillStripMatchedHits(iEvent, *theTTRHBuilder, tTopo, monoStereoClusterList);
1823  }
1824 
1825  if(includePhase2OTHits_){
1826  LogDebug("TrackingNtuple") << "foundPhase2OTSimLinks" ;
1827  const auto& phase2OTSimLinks = *siphase2OTSimLinksHandle;
1828  fillPhase2OTHits(iEvent, clusterToTPMap, tpKeyToIndex, *simHitsTPAssoc, phase2OTSimLinks, *theTTRHBuilder, tTopo, simHitRefKeyToIndex, hitProductIds);
1829  }
1830  }
1831 
1832  //seeds
1833  if(includeSeeds_) {
1834  fillSeeds(iEvent, tpCollection, tpKeyToIndex, bs, associatorByHits, *theTTRHBuilder, theMF.product(), monoStereoClusterList, hitProductIds, seedCollToOffset);
1835  }
1836 
1837  //tracks
1838  edm::Handle<edm::View<reco::Track> > tracksHandle;
1839  iEvent.getByToken(trackToken_, tracksHandle);
1840  const edm::View<reco::Track>& tracks = *tracksHandle;
1841  // The associator interfaces really need to be fixed...
1843  for(edm::View<Track>::size_type i=0; i<tracks.size(); ++i) {
1844  trackRefs.push_back(tracks.refAt(i));
1845  }
1846  fillTracks(trackRefs, tpCollection, tpKeyToIndex, bs, associatorByHits, *theTTRHBuilder, tTopo, hitProductIds, seedCollToOffset);
1847 
1848  //tracking particles
1849  //sort association maps with simHits
1850  std::sort( tpHitList.begin(), tpHitList.end(), tpHitIndexListLessSort );
1851  fillTrackingParticles(iEvent, iSetup, trackRefs, bs, tpCollection, tvKeyToIndex, associatorByHits, tpHitList);
1852 
1853  // vertices
1855  iEvent.getByToken(vertexToken_, vertices);
1856  fillVertices(*vertices, trackRefs);
1857 
1858  // tracking vertices
1859  fillTrackingVertices(tvRefs, tpKeyToIndex);
1860 
1861  t->Fill();
1862 
1863 }
1864 
1866  bsp_x = bs.x0();
1867  bsp_y = bs.y0();
1868  bsp_z = bs.x0();
1869  bsp_sigmax = bs.BeamWidthX();
1870  bsp_sigmay = bs.BeamWidthY();
1871  bsp_sigmaz = bs.sigmaZ();
1872 }
1873 
1874 namespace {
1875  template <typename SimLink> struct GetCluster;
1876  template <>
1877  struct GetCluster<PixelDigiSimLink> {
1878  static const SiPixelCluster& call(const OmniClusterRef& cluster) { return cluster.pixelCluster(); }
1879  };
1880  template <>
1881  struct GetCluster<StripDigiSimLink> {
1882  static const SiStripCluster& call(const OmniClusterRef& cluster) { return cluster.stripCluster(); }
1883  };
1884 }
1885 
1886 template <typename SimLink>
1888  DetId hitId, int clusterKey,
1890  const ClusterTPAssociation& clusterToTPMap,
1891  const TrackingParticleRefKeyToIndex& tpKeyToIndex,
1893  const edm::DetSetVector<SimLink>& digiSimLinks,
1894  const SimHitRefKeyToIndex& simHitRefKeyToIndex,
1895  HitType hitType
1896  ) {
1897  SimHitData ret;
1898 
1899  std::map<unsigned int, double> simTrackIdToChargeFraction;
1900  if(hitType == HitType::Phase2OT) simTrackIdToChargeFraction = chargeFraction(cluster.phase2OTCluster(), hitId, digiSimLinks);
1901  else simTrackIdToChargeFraction = chargeFraction(GetCluster<SimLink>::call(cluster), hitId, digiSimLinks);
1902 
1903  ret.type = HitSimType::Noise;
1904  auto range = clusterToTPMap.equal_range( cluster );
1905  if( range.first != range.second ) {
1906  for( auto ip=range.first; ip != range.second; ++ip ) {
1907  const TrackingParticleRef& trackingParticle = ip->second;
1908 
1909  // Find out if the cluster is from signal/ITPU/OOTPU
1910  const auto event = trackingParticle->eventId().event();
1911  const auto bx = trackingParticle->eventId().bunchCrossing();
1913  if(bx == 0) {
1914  type = (event == 0 ? HitSimType::Signal : HitSimType::ITPileup);
1915  }
1916  ret.type = static_cast<HitSimType>(std::min(static_cast<int>(ret.type), static_cast<int>(type)));
1917 
1918  // Limit to only input TrackingParticles (usually signal+ITPU)
1919  auto tpIndex = tpKeyToIndex.find(trackingParticle.key());
1920  if( tpIndex == tpKeyToIndex.end())
1921  continue;
1922 
1923  //now get the corresponding sim hit
1924  std::pair<TrackingParticleRef, TrackPSimHitRef> simHitTPpairWithDummyTP(trackingParticle,TrackPSimHitRef());
1925  //SimHit is dummy: for simHitTPAssociationListGreater sorting only the TP is needed
1926  auto range = std::equal_range(simHitsTPAssoc.begin(), simHitsTPAssoc.end(),
1928  int simHitKey = -1;
1929  bool foundElectron = false;
1930  edm::ProductID simHitID;
1931  for(auto ip = range.first; ip != range.second; ++ip) {
1932  TrackPSimHitRef TPhit = ip->second;
1933  DetId dId = DetId(TPhit->detUnitId());
1934  if (dId.rawId()==hitId.rawId()) {
1935  // skip electron SimHits for non-electron TPs also here
1936  if(std::abs(TPhit->particleType()) == 11 && std::abs(trackingParticle->pdgId()) != 11) {
1937  foundElectron = true;
1938  continue;
1939  }
1940 
1941  simHitKey = TPhit.key();
1942  simHitID = TPhit.id();
1943  break;
1944  }
1945  }
1946  if(simHitKey < 0) {
1947  // In case we didn't find a simhit because of filtered-out
1948  // electron SimHit, just ignore the missing SimHit.
1949  if(foundElectron)
1950  continue;
1951 
1952  auto ex = cms::Exception("LogicError") << "Did not find SimHit for reco hit DetId " << hitId.rawId()
1953  << " for TP " << trackingParticle.key() << " bx:event " << bx << ":" << event
1954  << ".\nFound SimHits from detectors ";
1955  for(auto ip = range.first; ip != range.second; ++ip) {
1956  TrackPSimHitRef TPhit = ip->second;
1957  DetId dId = DetId(TPhit->detUnitId());
1958  ex << dId.rawId() << " ";
1959  }
1960  if(trackingParticle->eventId().event() != 0) {
1961  ex << "\nSince this is a TrackingParticle from pileup, check that you're running the pileup mixing in playback mode.";
1962  }
1963  throw ex;
1964  }
1965  auto simHitIndex = simHitRefKeyToIndex.at(std::make_pair(simHitKey, simHitID));
1966  ret.matchingSimHit.push_back(simHitIndex);
1967 
1968  double chargeFraction = 0.;
1969  for(const SimTrack& simtrk: trackingParticle->g4Tracks()) {
1970  auto found = simTrackIdToChargeFraction.find(simtrk.trackId());
1971  if(found != simTrackIdToChargeFraction.end()) {
1972  chargeFraction += found->second;
1973  }
1974  }
1975  ret.chargeFraction.push_back(chargeFraction);
1976 
1977  // only for debug prints
1978  ret.bunchCrossing.push_back(bx);
1979  ret.event.push_back(event);
1980 
1981  simhit_hitIdx[simHitIndex].push_back(clusterKey);
1982  simhit_hitType[simHitIndex].push_back(static_cast<int>(hitType));
1983  }
1984  }
1985 
1986  return ret;
1987 }
1988 
1990  const TrackingParticleRefKeyToIndex& tpKeyToIndex,
1992  const TrackerTopology& tTopo,
1993  SimHitRefKeyToIndex& simHitRefKeyToIndex,
1994  std::vector<TPHitIndex>& tpHitList) {
1995 
1996  for(const auto& assoc: simHitsTPAssoc) {
1997  auto tpKey = assoc.first.key();
1998 
1999  // SimHitTPAssociationList can contain more TrackingParticles than
2000  // what are given to this EDAnalyzer, so we can filter those out here.
2001  auto found = tpKeyToIndex.find(tpKey);
2002  if(found == tpKeyToIndex.end())
2003  continue;
2004  const auto tpIndex = found->second;
2005 
2006  // skip non-tracker simhits (mostly muons)
2007  const auto& simhit = *(assoc.second);
2008  auto detId = DetId(simhit.detUnitId());
2009  if(detId.det() != DetId::Tracker) continue;
2010 
2011  // Skip electron SimHits for non-electron TrackingParticles to
2012  // filter out delta rays. The delta ray hits just confuse. If we
2013  // need them later, let's add them as a separate "collection" of
2014  // hits of a TP
2015  const TrackingParticle& tp = *(assoc.first);
2016  if(std::abs(simhit.particleType()) == 11 && std::abs(tp.pdgId()) != 11) continue;
2017 
2018  auto simHitKey = std::make_pair(assoc.second.key(), assoc.second.id());
2019 
2020  if(simHitRefKeyToIndex.find(simHitKey) != simHitRefKeyToIndex.end()) {
2021  for(const auto& assoc2: simHitsTPAssoc) {
2022  if(std::make_pair(assoc2.second.key(), assoc2.second.id()) == simHitKey) {
2023 
2024 #ifdef EDM_ML_DEBUG
2025  auto range1 = std::equal_range(simHitsTPAssoc.begin(), simHitsTPAssoc.end(),
2026  std::make_pair(assoc.first, TrackPSimHitRef()),
2028  auto range2 = std::equal_range(simHitsTPAssoc.begin(), simHitsTPAssoc.end(),
2029  std::make_pair(assoc2.first, TrackPSimHitRef()),
2031 
2032  LogTrace("TrackingNtuple") << "Earlier TP " << assoc2.first.key() << " SimTrack Ids";
2033  for(const auto& simTrack: assoc2.first->g4Tracks()) {
2034  edm::LogPrint("TrackingNtuple") << " SimTrack " << simTrack.trackId() << " BX:event " << simTrack.eventId().bunchCrossing() << ":" << simTrack.eventId().event();
2035  }
2036  for(auto iHit = range2.first; iHit != range2.second; ++iHit) {
2037  LogTrace("TrackingNtuple") << " SimHit " << iHit->second.key() << " " << iHit->second.id() << " tof " << iHit->second->tof() << " trackId " << iHit->second->trackId() << " BX:event " << iHit->second->eventId().bunchCrossing() << ":" << iHit->second->eventId().event();
2038  }
2039  LogTrace("TrackingNtuple") << "Current TP " << assoc.first.key() << " SimTrack Ids";
2040  for(const auto& simTrack: assoc.first->g4Tracks()) {
2041  edm::LogPrint("TrackingNtuple") << " SimTrack " << simTrack.trackId() << " BX:event " << simTrack.eventId().bunchCrossing() << ":" << simTrack.eventId().event();
2042  }
2043  for(auto iHit = range1.first; iHit != range1.second; ++iHit) {
2044  LogTrace("TrackingNtuple") << " SimHit " << iHit->second.key() << " " << iHit->second.id() << " tof " << iHit->second->tof() << " trackId " << iHit->second->trackId() << " BX:event " << iHit->second->eventId().bunchCrossing() << ":" << iHit->second->eventId().event();
2045  }
2046 #endif
2047 
2048  throw cms::Exception("LogicError") << "Got second time the SimHit " << simHitKey.first << " of " << simHitKey.second << ", first time with TrackingParticle " << assoc2.first.key() << ", now with " << tpKey;
2049  }
2050  }
2051  throw cms::Exception("LogicError") << "Got second time the SimHit " << simHitKey.first << " of " << simHitKey.second << ", now with TrackingParticle " << tpKey << ", but I didn't find the first occurrance!";
2052  }
2053 
2054  auto det = tracker.idToDetUnit(detId);
2055  if(!det)
2056  throw cms::Exception("LogicError") << "Did not find a det unit for DetId " << simhit.detUnitId() << " from tracker geometry";
2057 
2058  const auto pos = det->surface().toGlobal(simhit.localPosition());
2059  const float tof = simhit.timeOfFlight();
2060 
2061  const auto simHitIndex = simhit_x.size();
2062  simHitRefKeyToIndex[simHitKey] = simHitIndex;
2063 
2064  if(includeStripHits_) simhit_detId.push_back(tTopo, detId);
2065  else simhit_detId_phase2.push_back(tTopo, detId);
2066  simhit_x.push_back(pos.x());
2067  simhit_y.push_back(pos.y());
2068  simhit_z.push_back(pos.z());
2069  simhit_particle.push_back(simhit.particleType());
2070  simhit_process.push_back(simhit.processType());
2071  simhit_eloss.push_back(simhit.energyLoss());
2072  simhit_tof.push_back(tof);
2073  //simhit_simTrackId.push_back(simhit.trackId());
2074 
2075  simhit_simTrkIdx.push_back(tpIndex);
2076 
2077  simhit_hitIdx.emplace_back(); // filled in matchCluster
2078  simhit_hitType.emplace_back(); // filled in matchCluster
2079 
2080  tpHitList.emplace_back(tpKey, simHitIndex, tof, simhit.detUnitId());
2081  }
2082 }
2083 
2085  const ClusterTPAssociation& clusterToTPMap,
2086  const TrackingParticleRefKeyToIndex& tpKeyToIndex,
2088  const edm::DetSetVector<PixelDigiSimLink>& digiSimLink,
2089  const TransientTrackingRecHitBuilder& theTTRHBuilder,
2090  const TrackerTopology& tTopo,
2091  const SimHitRefKeyToIndex& simHitRefKeyToIndex,
2092  std::set<edm::ProductID>& hitProductIds
2093  ) {
2095  iEvent.getByToken(pixelRecHitToken_, pixelHits);
2096  for (auto it = pixelHits->begin(); it!=pixelHits->end(); it++ ) {
2097  const DetId hitId = it->detId();
2098  for (auto hit = it->begin(); hit!=it->end(); hit++ ) {
2099  TransientTrackingRecHit::RecHitPointer ttrh = theTTRHBuilder.build(&*hit);
2100 
2101  hitProductIds.insert(hit->cluster().id());
2102 
2103  const int key = hit->cluster().key();
2104  const int lay = tTopo.layer(hitId);
2105  SimHitData simHitData = matchCluster(hit->firstClusterRef(), hitId, key, ttrh,
2106  clusterToTPMap, tpKeyToIndex, simHitsTPAssoc, digiSimLink, simHitRefKeyToIndex, HitType::Pixel);
2107 
2108  pix_isBarrel .push_back( hitId.subdetId()==1 );
2109  pix_detId .push_back( tTopo, hitId );
2110  pix_trkIdx .emplace_back(); // filled in fillTracks
2111  pix_seeIdx .emplace_back(); // filled in fillSeeds
2112  pix_simHitIdx.push_back( simHitData.matchingSimHit );
2113  pix_simType.push_back( static_cast<int>(simHitData.type) );
2114  pix_x .push_back( ttrh->globalPosition().x() );
2115  pix_y .push_back( ttrh->globalPosition().y() );
2116  pix_z .push_back( ttrh->globalPosition().z() );
2117  pix_xx .push_back( ttrh->globalPositionError().cxx() );
2118  pix_xy .push_back( ttrh->globalPositionError().cyx() );
2119  pix_yy .push_back( ttrh->globalPositionError().cyy() );
2120  pix_yz .push_back( ttrh->globalPositionError().czy() );
2121  pix_zz .push_back( ttrh->globalPositionError().czz() );
2122  pix_zx .push_back( ttrh->globalPositionError().czx() );
2123  pix_chargeFraction.push_back( simHitData.chargeFraction );
2124  pix_radL .push_back( ttrh->surface()->mediumProperties().radLen() );
2125  pix_bbxi .push_back( ttrh->surface()->mediumProperties().xi() );
2126  LogTrace("TrackingNtuple") << "pixHit cluster=" << key
2127  << " subdId=" << hitId.subdetId()
2128  << " lay=" << lay
2129  << " rawId=" << hitId.rawId()
2130  << " pos =" << ttrh->globalPosition()
2131  << " nMatchingSimHit=" << simHitData.matchingSimHit.size();
2132  if(!simHitData.matchingSimHit.empty()) {
2133  const auto simHitIdx = simHitData.matchingSimHit[0];
2134  LogTrace("TrackingNtuple") << " firstMatchingSimHit=" << simHitIdx
2135  << " simHitPos=" << GlobalPoint(simhit_x[simHitIdx], simhit_y[simHitIdx], simhit_z[simHitIdx])
2136  << " energyLoss=" << simhit_eloss[simHitIdx]
2137  << " particleType=" << simhit_particle[simHitIdx]
2138  << " processType=" << simhit_process[simHitIdx]
2139  << " bunchCrossing=" << simHitData.bunchCrossing[0]
2140  << " event=" << simHitData.event[0];
2141  }
2142  }
2143  }
2144 }
2145 
2146 
2148  const ClusterTPAssociation& clusterToTPMap,
2149  const TrackingParticleRefKeyToIndex& tpKeyToIndex,
2151  const edm::DetSetVector<StripDigiSimLink>& digiSimLink,
2152  const TransientTrackingRecHitBuilder& theTTRHBuilder,
2153  const TrackerTopology& tTopo,
2154  const SimHitRefKeyToIndex& simHitRefKeyToIndex,
2155  std::set<edm::ProductID>& hitProductIds
2156  ) {
2157  //index strip hit branches by cluster index
2159  iEvent.getByToken(stripRphiRecHitToken_, rphiHits);
2161  iEvent.getByToken(stripStereoRecHitToken_, stereoHits);
2162  int totalStripHits = rphiHits->dataSize()+stereoHits->dataSize();
2163  str_isBarrel .resize(totalStripHits);
2164  str_detId .resize(totalStripHits);
2165  str_trkIdx .resize(totalStripHits); // filled in fillTracks
2166  str_seeIdx .resize(totalStripHits); // filled in fillSeeds
2167  str_simHitIdx.resize(totalStripHits);
2168  str_simType .resize(totalStripHits);
2169  str_x .resize(totalStripHits);
2170  str_y .resize(totalStripHits);
2171  str_z .resize(totalStripHits);
2172  str_xx .resize(totalStripHits);
2173  str_xy .resize(totalStripHits);
2174  str_yy .resize(totalStripHits);
2175  str_yz .resize(totalStripHits);
2176  str_zz .resize(totalStripHits);
2177  str_zx .resize(totalStripHits);
2178  str_chargeFraction.resize(totalStripHits);
2179  str_radL .resize(totalStripHits);
2180  str_bbxi .resize(totalStripHits);
2181 
2182  auto fill = [&](const SiStripRecHit2DCollection& hits, const char *name) {
2183  for(const auto& detset: hits) {
2184  const DetId hitId = detset.detId();
2185  for(const auto& hit: detset) {
2186  TransientTrackingRecHit::RecHitPointer ttrh = theTTRHBuilder.build(&hit);
2187 
2188  hitProductIds.insert(hit.cluster().id());
2189 
2190  const int key = hit.cluster().key();
2191  const int lay = tTopo.layer(hitId);
2192  SimHitData simHitData = matchCluster(hit.firstClusterRef(), hitId, key, ttrh,
2193  clusterToTPMap, tpKeyToIndex, simHitsTPAssoc, digiSimLink, simHitRefKeyToIndex, HitType::Strip);
2195  str_detId.set(key, tTopo, hitId);
2196  str_simHitIdx[key] = simHitData.matchingSimHit;
2197  str_simType [key] = static_cast<int>(simHitData.type);
2198  str_x [key] = ttrh->globalPosition().x();
2199  str_y [key] = ttrh->globalPosition().y();
2200  str_z [key] = ttrh->globalPosition().z();
2201  str_xx [key] = ttrh->globalPositionError().cxx();
2202  str_xy [key] = ttrh->globalPositionError().cyx();
2203  str_yy [key] = ttrh->globalPositionError().cyy();
2204  str_yz [key] = ttrh->globalPositionError().czy();
2205  str_zz [key] = ttrh->globalPositionError().czz();
2206  str_zx [key] = ttrh->globalPositionError().czx();
2207  str_chargeFraction[key] = simHitData.chargeFraction;
2208  str_radL [key] = ttrh->surface()->mediumProperties().radLen();
2209  str_bbxi [key] = ttrh->surface()->mediumProperties().xi();
2210  LogTrace("TrackingNtuple") << name << " cluster=" << key
2211  << " subdId=" << hitId.subdetId()
2212  << " lay=" << lay
2213  << " rawId=" << hitId.rawId()
2214  << " pos =" << ttrh->globalPosition()
2215  << " nMatchingSimHit=" << simHitData.matchingSimHit.size();
2216  if(!simHitData.matchingSimHit.empty()) {
2217  const auto simHitIdx = simHitData.matchingSimHit[0];
2218  LogTrace("TrackingNtuple") << " firstMatchingSimHit=" << simHitIdx
2219  << " simHitPos=" << GlobalPoint(simhit_x[simHitIdx], simhit_y[simHitIdx], simhit_z[simHitIdx])
2220  << " simHitPos=" << GlobalPoint(simhit_x[simHitIdx], simhit_y[simHitIdx], simhit_z[simHitIdx])
2221  << " energyLoss=" << simhit_eloss[simHitIdx]
2222  << " particleType=" << simhit_particle[simHitIdx]
2223  << " processType=" << simhit_process[simHitIdx]
2224  << " bunchCrossing=" << simHitData.bunchCrossing[0]
2225  << " event=" << simHitData.event[0];
2226  }
2227  }
2228  }
2229  };
2230 
2231  fill(*rphiHits, "stripRPhiHit");
2232  fill(*stereoHits, "stripStereoHit");
2233 }
2234 
2236  const TransientTrackingRecHitBuilder& theTTRHBuilder,
2237  const TrackerTopology& tTopo,
2238  std::vector<std::pair<int, int> >& monoStereoClusterList
2239  ) {
2241  iEvent.getByToken(stripMatchedRecHitToken_, matchedHits);
2242  for (auto it = matchedHits->begin(); it!=matchedHits->end(); it++ ) {
2243  const DetId hitId = it->detId();
2244  for (auto hit = it->begin(); hit!=it->end(); hit++ ) {
2245  TransientTrackingRecHit::RecHitPointer ttrh = theTTRHBuilder.build(&*hit);
2246  const int lay = tTopo.layer(hitId);
2247  monoStereoClusterList.emplace_back(hit->monoHit().cluster().key(),hit->stereoHit().cluster().key());
2248  glu_isBarrel .push_back( (hitId.subdetId()==StripSubdetector::TIB || hitId.subdetId()==StripSubdetector::TOB) );
2249  glu_detId .push_back( tTopo, hitId );
2250  glu_monoIdx .push_back( hit->monoHit().cluster().key() );
2251  glu_stereoIdx.push_back( hit->stereoHit().cluster().key() );
2252  glu_seeIdx .emplace_back(); // filled in fillSeeds
2253  glu_x .push_back( ttrh->globalPosition().x() );
2254  glu_y .push_back( ttrh->globalPosition().y() );
2255  glu_z .push_back( ttrh->globalPosition().z() );
2256  glu_xx .push_back( ttrh->globalPositionError().cxx() );
2257  glu_xy .push_back( ttrh->globalPositionError().cyx() );
2258  glu_yy .push_back( ttrh->globalPositionError().cyy() );
2259  glu_yz .push_back( ttrh->globalPositionError().czy() );
2260  glu_zz .push_back( ttrh->globalPositionError().czz() );
2261  glu_zx .push_back( ttrh->globalPositionError().czx() );
2262  glu_radL .push_back( ttrh->surface()->mediumProperties().radLen() );
2263  glu_bbxi .push_back( ttrh->surface()->mediumProperties().xi() );
2264  LogTrace("TrackingNtuple") << "stripMatchedHit"
2265  << " cluster0=" << hit->stereoHit().cluster().key()
2266  << " cluster1=" << hit->monoHit().cluster().key()
2267  << " subdId=" << hitId.subdetId()
2268  << " lay=" << lay
2269  << " rawId=" << hitId.rawId()
2270  << " pos =" << ttrh->globalPosition();
2271  }
2272  }
2273 }
2274 
2276  const ClusterTPAssociation& clusterToTPMap,
2277  const TrackingParticleRefKeyToIndex& tpKeyToIndex,
2279  const edm::DetSetVector<PixelDigiSimLink>& digiSimLink,
2280  const TransientTrackingRecHitBuilder& theTTRHBuilder,
2281  const TrackerTopology& tTopo,
2282  const SimHitRefKeyToIndex& simHitRefKeyToIndex,
2283  std::set<edm::ProductID>& hitProductIds
2284  ) {
2286  iEvent.getByToken(phase2OTRecHitToken_, phase2OTHits);
2287  for (auto it = phase2OTHits->begin(); it!=phase2OTHits->end(); it++ ) {
2288  const DetId hitId = it->detId();
2289  for (auto hit = it->begin(); hit!=it->end(); hit++ ) {
2290  TransientTrackingRecHit::RecHitPointer ttrh = theTTRHBuilder.build(&*hit);
2291 
2292  hitProductIds.insert(hit->cluster().id());
2293 
2294  const int key = hit->cluster().key();
2295  const int lay = tTopo.layer(hitId);
2296  SimHitData simHitData = matchCluster(hit->firstClusterRef(), hitId, key, ttrh,
2297  clusterToTPMap, tpKeyToIndex, simHitsTPAssoc, digiSimLink, simHitRefKeyToIndex, HitType::Phase2OT);
2298 
2299  ph2_isBarrel .push_back( hitId.subdetId()==1 );
2300  ph2_detId .push_back( tTopo, hitId );
2301  ph2_trkIdx .emplace_back(); // filled in fillTracks
2302  ph2_seeIdx .emplace_back(); // filled in fillSeeds
2303  ph2_simHitIdx.push_back( simHitData.matchingSimHit );
2304  ph2_simType.push_back( static_cast<int>(simHitData.type) );
2305  ph2_x .push_back( ttrh->globalPosition().x() );
2306  ph2_y .push_back( ttrh->globalPosition().y() );
2307  ph2_z .push_back( ttrh->globalPosition().z() );
2308  ph2_xx .push_back( ttrh->globalPositionError().cxx() );
2309  ph2_xy .push_back( ttrh->globalPositionError().cyx() );
2310  ph2_yy .push_back( ttrh->globalPositionError().cyy() );
2311  ph2_yz .push_back( ttrh->globalPositionError().czy() );
2312  ph2_zz .push_back( ttrh->globalPositionError().czz() );
2313  ph2_zx .push_back( ttrh->globalPositionError().czx() );
2314  ph2_radL .push_back( ttrh->surface()->mediumProperties().radLen() );
2315  ph2_bbxi .push_back( ttrh->surface()->mediumProperties().xi() );
2316 
2317  LogTrace("TrackingNtuple") << "phase2 OT cluster=" << key
2318  << " subdId=" << hitId.subdetId()
2319  << " lay=" << lay
2320  << " rawId=" << hitId.rawId()
2321  << " pos =" << ttrh->globalPosition()
2322  << " nMatchingSimHit=" << simHitData.matchingSimHit.size();
2323 
2324  if(!simHitData.matchingSimHit.empty()) {
2325  const auto simHitIdx = simHitData.matchingSimHit[0];
2326  LogTrace("TrackingNtuple") << " firstMatchingSimHit=" << simHitIdx
2327  << " simHitPos=" << GlobalPoint(simhit_x[simHitIdx], simhit_y[simHitIdx], simhit_z[simHitIdx])
2328  << " energyLoss=" << simhit_eloss[simHitIdx]
2329  << " particleType=" << simhit_particle[simHitIdx]
2330  << " processType=" << simhit_process[simHitIdx]
2331  << " bunchCrossing=" << simHitData.bunchCrossing[0]
2332  << " event=" << simHitData.event[0];
2333  }
2334  }
2335  }
2336 }
2337 
2338 
2340  const TrackingParticleRefVector& tpCollection,
2341  const TrackingParticleRefKeyToIndex& tpKeyToIndex,
2342  const reco::BeamSpot& bs,
2343  const reco::TrackToTrackingParticleAssociator& associatorByHits,
2344  const TransientTrackingRecHitBuilder& theTTRHBuilder,
2345  const MagneticField *theMF,
2346  const std::vector<std::pair<int, int> >& monoStereoClusterList,
2347  const std::set<edm::ProductID>& hitProductIds,
2348  std::map<edm::ProductID, size_t>& seedCollToOffset
2349  ) {
2350  TSCBLBuilderNoMaterial tscblBuilder;
2351  for(size_t iColl=0; iColl < seedTokens_.size(); ++iColl) {
2352  const auto& seedToken = seedTokens_[iColl];
2353 
2354  edm::Handle<edm::View<reco::Track> > seedTracksHandle;
2355  iEvent.getByToken(seedToken, seedTracksHandle);
2356  const auto& seedTracks = *seedTracksHandle;
2357 
2358  if(seedTracks.empty())
2359  continue;
2360 
2362  labelsForToken(seedToken, labels);
2363 
2364  const auto& seedStopReasonToken = seedStopReasonTokens_[iColl];
2365  edm::Handle<std::vector<short> > seedStopReasonHandle;
2366  iEvent.getByToken(seedStopReasonToken, seedStopReasonHandle);
2367  const auto& seedStopReasons = *seedStopReasonHandle;
2368  if(seedTracks.size() != seedStopReasons.size()) {
2370  labelsForToken(seedStopReasonToken, labels2);
2371 
2372  throw cms::Exception("LogicError") << "Got " << seedTracks.size() << " seeds, but " << seedStopReasons.size() << " seed stopping reasons for collections " << labels.module << ", " << labels2.module;
2373  }
2374 
2375  // The associator interfaces really need to be fixed...
2376  edm::RefToBaseVector<reco::Track> seedTrackRefs;
2377  for(edm::View<reco::Track>::size_type i=0; i<seedTracks.size(); ++i) {
2378  seedTrackRefs.push_back(seedTracks.refAt(i));
2379  }
2380  reco::RecoToSimCollection recSimColl = associatorByHits.associateRecoToSim(seedTrackRefs, tpCollection);
2381  reco::SimToRecoCollection simRecColl = associatorByHits.associateSimToReco(seedTrackRefs, tpCollection);
2382 
2383  TString label = labels.module;
2384  //format label to match algoName
2385  label.ReplaceAll("seedTracks", "");
2386  label.ReplaceAll("Seeds","");
2387  label.ReplaceAll("muonSeeded","muonSeededStep");
2388  int algo = reco::TrackBase::algoByName(label.Data());
2389 
2390  edm::ProductID id = seedTracks[0].seedRef().id();
2391  const auto offset = see_fitok.size();
2392  auto inserted = seedCollToOffset.emplace(id, offset);
2393  if(!inserted.second)
2394  throw cms::Exception("Configuration") << "Trying to add seeds with ProductID " << id << " for a second time from collection " << labels.module << ", seed algo " << label << ". Typically this is caused by a configuration problem.";
2395  see_offset.push_back(offset);
2396 
2397  LogTrace("TrackingNtuple") << "NEW SEED LABEL: " << label << " size: " << seedTracks.size() << " algo=" << algo
2398  << " ProductID " << id;
2399 
2400  for(size_t iSeed=0; iSeed < seedTrackRefs.size(); ++iSeed) {
2401  const auto& seedTrackRef = seedTrackRefs[iSeed];
2402  const auto& seedTrack = *seedTrackRef;
2403  const auto& seedRef = seedTrack.seedRef();
2404  const auto& seed = *seedRef;
2405 
2406  const auto seedStopReason = seedStopReasons[iSeed];
2407 
2408  if(seedRef.id() != id)
2409  throw cms::Exception("LogicError") << "All tracks in 'TracksFromSeeds' collection should point to seeds in the same collection. Now the element 0 had ProductID " << id << " while the element " << seedTrackRef.key() << " had " << seedTrackRef.id() << ". The source collection is " << labels.module << ".";
2410 
2411  std::vector<float> sharedFraction;
2412  std::vector<int> tpIdx;
2413  auto foundTPs = recSimColl.find(seedTrackRef);
2414  if (foundTPs != recSimColl.end()) {
2415  for(const auto tpQuality: foundTPs->val) {
2416  sharedFraction.push_back(tpQuality.second);
2417  tpIdx.push_back( tpKeyToIndex.at( tpQuality.first.key() ) );
2418  }
2419  }
2420 
2421 
2422  const bool seedFitOk = !trackFromSeedFitFailed(seedTrack);
2423  const int charge = seedTrack.charge();
2424  const float pt = seedFitOk ? seedTrack.pt() : 0;
2425  const float eta = seedFitOk ? seedTrack.eta() : 0;
2426  const float phi = seedFitOk ? seedTrack.phi() : 0;
2427  const int nHits = seedTrack.numberOfValidHits();
2428 
2429  const auto seedIndex = see_fitok.size();
2430 
2431  see_fitok .push_back(seedFitOk);
2432 
2433  see_px .push_back( seedFitOk ? seedTrack.px() : 0 );
2434  see_py .push_back( seedFitOk ? seedTrack.py() : 0 );
2435  see_pz .push_back( seedFitOk ? seedTrack.pz() : 0 );
2436  see_pt .push_back( pt );
2437  see_eta .push_back( eta );
2438  see_phi .push_back( phi );
2439  see_q .push_back( charge );
2440  see_nValid .push_back( nHits );
2441 
2442  see_dxy .push_back( seedFitOk ? seedTrack.dxy(bs.position()) : 0);
2443  see_dz .push_back( seedFitOk ? seedTrack.dz(bs.position()) : 0);
2444  see_ptErr .push_back( seedFitOk ? seedTrack.ptError() : 0);
2445  see_etaErr .push_back( seedFitOk ? seedTrack.etaError() : 0);
2446  see_phiErr .push_back( seedFitOk ? seedTrack.phiError() : 0);
2447  see_dxyErr .push_back( seedFitOk ? seedTrack.dxyError() : 0);
2448  see_dzErr .push_back( seedFitOk ? seedTrack.dzError() : 0);
2449  see_algo .push_back( algo );
2450  see_stopReason.push_back( seedStopReason );
2451 
2452  const auto& state = seedTrack.seedRef()->startingState();
2453  const auto& pos = state.parameters().position();
2454  const auto& mom = state.parameters().momentum();
2455  see_statePt.push_back(state.pt());
2456  see_stateTrajX.push_back(pos.x());
2457  see_stateTrajY.push_back(pos.y());
2458  see_stateTrajPx.push_back(mom.x());
2459  see_stateTrajPy.push_back(mom.y());
2460  see_stateTrajPz.push_back(mom.z());
2461 
2462  see_trkIdx .push_back(-1); // to be set correctly in fillTracks
2463  see_shareFrac.push_back( sharedFraction );
2464  see_simTrkIdx.push_back( tpIdx );
2465 
2467  /*
2468  TransientTrackingRecHit::RecHitPointer lastRecHit = theTTRHBuilder.build(&*(seed.recHits().second-1));
2469  TrajectoryStateOnSurface state = trajectoryStateTransform::transientState( itSeed->startingState(), lastRecHit->surface(), theMF);
2470  float pt = state.globalParameters().momentum().perp();
2471  float eta = state.globalParameters().momentum().eta();
2472  float phi = state.globalParameters().momentum().phi();
2473  see_px .push_back( state.globalParameters().momentum().x() );
2474  see_py .push_back( state.globalParameters().momentum().y() );
2475  see_pz .push_back( state.globalParameters().momentum().z() );
2476  */
2477 
2478  std::vector<int> hitIdx;
2479  std::vector<int> hitType;
2480 
2481  for (auto hit=seed.recHits().first; hit!=seed.recHits().second; ++hit) {
2483  int subid = recHit->geographicalId().subdetId();
2484  if (subid == (int) PixelSubdetector::PixelBarrel || subid == (int) PixelSubdetector::PixelEndcap) {
2485  const BaseTrackerRecHit* bhit = dynamic_cast<const BaseTrackerRecHit*>(&*recHit);
2486  const auto& clusterRef = bhit->firstClusterRef();
2487  const auto clusterKey = clusterRef.cluster_pixel().key();
2488  if(includeAllHits_) {
2489  checkProductID(hitProductIds, clusterRef.id(), "seed");
2490  pix_seeIdx[clusterKey].push_back(seedIndex);
2491  }
2492  hitIdx.push_back( clusterKey );
2493  hitType.push_back( static_cast<int>(HitType::Pixel) );
2494  } else if (subid == (int) StripSubdetector::TOB || subid == (int) StripSubdetector::TID ||
2495  subid == (int) StripSubdetector::TIB || subid == (int) StripSubdetector::TEC) {
2496  if (trackerHitRTTI::isMatched(*recHit)) {
2497  const SiStripMatchedRecHit2D * matchedHit = dynamic_cast<const SiStripMatchedRecHit2D *>(&*recHit);
2498  if(includeAllHits_) {
2499  checkProductID(hitProductIds, matchedHit->monoClusterRef().id(), "seed");
2500  checkProductID(hitProductIds, matchedHit->stereoClusterRef().id(), "seed");
2501  }
2502  int monoIdx = matchedHit->monoClusterRef().key();
2503  int stereoIdx = matchedHit->stereoClusterRef().key();
2504 
2505  std::vector<std::pair<int,int> >::const_iterator pos = find( monoStereoClusterList.begin(), monoStereoClusterList.end(), std::make_pair(monoIdx,stereoIdx) );
2506  const auto gluedIndex = std::distance(monoStereoClusterList.begin(), pos);
2507  if(includeAllHits_) glu_seeIdx[gluedIndex].push_back(seedIndex);
2508  hitIdx.push_back( gluedIndex );
2509  hitType.push_back( static_cast<int>(HitType::Glued) );
2510  } else {
2511  const BaseTrackerRecHit* bhit = dynamic_cast<const BaseTrackerRecHit*>(&*recHit);
2512  const auto& clusterRef = bhit->firstClusterRef();
2513  unsigned int clusterKey;
2514  if(clusterRef.isPhase2()){
2515  clusterKey = clusterRef.cluster_phase2OT().key();
2516  } else {
2517  clusterKey = clusterRef.cluster_strip().key();
2518  }
2519 
2520  if(includeAllHits_) {
2521  checkProductID(hitProductIds, clusterRef.id(), "seed");
2522  if(clusterRef.isPhase2()){
2523  ph2_seeIdx[clusterKey].push_back(seedIndex);
2524  } else {
2525  str_seeIdx[clusterKey].push_back(seedIndex);
2526  }
2527  }
2528 
2529  hitIdx.push_back( clusterKey );
2530  if(clusterRef.isPhase2()){
2531  hitType.push_back( static_cast<int>(HitType::Phase2OT) );
2532  } else {
2533  hitType.push_back( static_cast<int>(HitType::Strip) );
2534  }
2535  }
2536  } else {
2537  LogTrace("TrackingNtuple") << " not pixel and not Strip detector";
2538  }
2539  }
2540  see_hitIdx .push_back( hitIdx );
2541  see_hitType .push_back( hitType );
2542  see_nPixel .push_back( std::count(hitType.begin(), hitType.end(), static_cast<int>(HitType::Pixel)) );
2543  see_nGlued .push_back( std::count(hitType.begin(), hitType.end(), static_cast<int>(HitType::Glued)) );
2544  see_nStrip .push_back( std::count(hitType.begin(), hitType.end(), static_cast<int>(HitType::Strip)) );
2545  see_nPhase2OT.push_back( std::count(hitType.begin(), hitType.end(), static_cast<int>(HitType::Phase2OT)) );
2546  //the part below is not strictly needed
2547  float chi2 = -1;
2548  if (nHits==2) {
2549  TransientTrackingRecHit::RecHitPointer recHit0 = theTTRHBuilder.build(&*(seed.recHits().first));
2550  TransientTrackingRecHit::RecHitPointer recHit1 = theTTRHBuilder.build(&*(seed.recHits().first+1));
2551  std::vector<GlobalPoint> gp(2);
2552  std::vector<GlobalError> ge(2);
2553  gp[0] = recHit0->globalPosition();
2554  ge[0] = recHit0->globalPositionError();
2555  gp[1] = recHit1->globalPosition();
2556  ge[1] = recHit1->globalPositionError();
2557  LogTrace("TrackingNtuple") << "seed " << seedTrackRef.key()
2558  << " pt=" << pt << " eta=" << eta << " phi=" << phi << " q=" << charge
2559  << " - PAIR - ids: " << recHit0->geographicalId().rawId() << " " << recHit1->geographicalId().rawId()
2560  << " hitpos: " << gp[0] << " " << gp[1]
2561  << " trans0: " << (recHit0->transientHits().size()>1 ? recHit0->transientHits()[0]->globalPosition() : GlobalPoint(0,0,0))
2562  << " " << (recHit0->transientHits().size()>1 ? recHit0->transientHits()[1]->globalPosition() : GlobalPoint(0,0,0))
2563  << " trans1: " << (recHit1->transientHits().size()>1 ? recHit1->transientHits()[0]->globalPosition() : GlobalPoint(0,0,0))
2564  << " " << (recHit1->transientHits().size()>1 ? recHit1->transientHits()[1]->globalPosition() : GlobalPoint(0,0,0))
2565  << " eta,phi: " << gp[0].eta() << "," << gp[0].phi();
2566  } else if (nHits==3) {
2567  TransientTrackingRecHit::RecHitPointer recHit0 = theTTRHBuilder.build(&*(seed.recHits().first));
2568  TransientTrackingRecHit::RecHitPointer recHit1 = theTTRHBuilder.build(&*(seed.recHits().first+1));
2569  TransientTrackingRecHit::RecHitPointer recHit2 = theTTRHBuilder.build(&*(seed.recHits().first+2));
2572  declareDynArray(bool,4, bl);
2573  gp[0] = recHit0->globalPosition();
2574  ge[0] = recHit0->globalPositionError();
2575  int subid0 = recHit0->geographicalId().subdetId();
2576  bl[0] = (subid0 == StripSubdetector::TIB || subid0 == StripSubdetector::TOB || subid0 == (int) PixelSubdetector::PixelBarrel);
2577  gp[1] = recHit1->globalPosition();
2578  ge[1] = recHit1->globalPositionError();
2579  int subid1 = recHit1->geographicalId().subdetId();
2580  bl[1] = (subid1 == StripSubdetector::TIB || subid1 == StripSubdetector::TOB || subid1 == (int) PixelSubdetector::PixelBarrel);
2581  gp[2] = recHit2->globalPosition();
2582  ge[2] = recHit2->globalPositionError();
2583  int subid2 = recHit2->geographicalId().subdetId();
2584  bl[2] = (subid2 == StripSubdetector::TIB || subid2 == StripSubdetector::TOB || subid2 == (int) PixelSubdetector::PixelBarrel);
2585  RZLine rzLine(gp,ge,bl);
2586  float seed_chi2 = rzLine.chi2();
2587  //float seed_pt = state.globalParameters().momentum().perp();
2588  float seed_pt = pt;
2589  LogTrace("TrackingNtuple") << "seed " << seedTrackRef.key()
2590  << " pt=" << pt << " eta=" << eta << " phi=" << phi << " q=" << charge
2591  << " - TRIPLET - ids: " << recHit0->geographicalId().rawId() << " " << recHit1->geographicalId().rawId() << " " << recHit2->geographicalId().rawId()
2592  << " hitpos: " << gp[0] << " " << gp[1] << " " << gp[2]
2593  << " trans0: " << (recHit0->transientHits().size()>1 ? recHit0->transientHits()[0]->globalPosition() : GlobalPoint(0,0,0))
2594  << " " << (recHit0->transientHits().size()>1 ? recHit0->transientHits()[1]->globalPosition() : GlobalPoint(0,0,0))
2595  << " trans1: " << (recHit1->transientHits().size()>1 ? recHit1->transientHits()[0]->globalPosition() : GlobalPoint(0,0,0))
2596  << " " << (recHit1->transientHits().size()>1 ? recHit1->transientHits()[1]->globalPosition() : GlobalPoint(0,0,0))
2597  << " trans2: " << (recHit2->transientHits().size()>1 ? recHit2->transientHits()[0]->globalPosition() : GlobalPoint(0,0,0))
2598  << " " << (recHit2->transientHits().size()>1 ? recHit2->transientHits()[1]->globalPosition() : GlobalPoint(0,0,0))
2599  << " local: " << recHit2->localPosition()
2600  //<< " tsos pos, mom: " << state.globalPosition()<<" "<<state.globalMomentum()
2601  << " eta,phi: " << gp[0].eta() << "," << gp[0].phi()
2602  << " pt,chi2: " << seed_pt << "," << seed_chi2;
2603  chi2 = seed_chi2;
2604  }
2605  see_chi2 .push_back( chi2 );
2606  }
2607 
2608  fillTrackingParticlesForSeeds(tpCollection, simRecColl, tpKeyToIndex, offset);
2609  }
2610 }
2611 
2613  const TrackingParticleRefVector& tpCollection,
2614  const TrackingParticleRefKeyToIndex& tpKeyToIndex,
2615  const reco::BeamSpot& bs,
2616  const reco::TrackToTrackingParticleAssociator& associatorByHits,
2617  const TransientTrackingRecHitBuilder& theTTRHBuilder,
2618  const TrackerTopology& tTopo,
2619  const std::set<edm::ProductID>& hitProductIds,
2620  const std::map<edm::ProductID, size_t>& seedCollToOffset
2621  ) {
2622  reco::RecoToSimCollection recSimColl = associatorByHits.associateRecoToSim(tracks, tpCollection);
2624  labelsForToken(trackToken_, labels);
2625  LogTrace("TrackingNtuple") << "NEW TRACK LABEL: " << labels.module;
2626  for(size_t iTrack = 0; iTrack<tracks.size(); ++iTrack) {
2627  const auto& itTrack = tracks[iTrack];
2628  int nSimHits = 0;
2629  bool isSimMatched = false;
2630  std::vector<float> sharedFraction;
2631  std::vector<int> tpIdx;
2632  auto foundTPs = recSimColl.find(itTrack);
2633  if (foundTPs != recSimColl.end()) {
2634  if (!foundTPs->val.empty()) {
2635  nSimHits = foundTPs->val[0].first->numberOfTrackerHits();
2636  isSimMatched = true;
2637  }
2638  for(const auto tpQuality: foundTPs->val) {
2639  sharedFraction.push_back(tpQuality.second);
2640  tpIdx.push_back( tpKeyToIndex.at( tpQuality.first.key() ) );
2641  }
2642  }
2643  int charge = itTrack->charge();
2644  float pt = itTrack->pt();
2645  float eta = itTrack->eta();
2646  const double lambda = itTrack->lambda();
2647  float chi2 = itTrack->normalizedChi2();
2648  float phi = itTrack->phi();
2649  int nHits = itTrack->numberOfValidHits();
2650  const reco::HitPattern& hp = itTrack->hitPattern();
2651  trk_px .push_back(itTrack->px());
2652  trk_py .push_back(itTrack->py());
2653  trk_pz .push_back(itTrack->pz());
2654  trk_pt .push_back(pt);
2655  trk_inner_px.push_back(itTrack->innerMomentum().x());
2656  trk_inner_py.push_back(itTrack->innerMomentum().y());
2657  trk_inner_pz.push_back(itTrack->innerMomentum().z());
2658  trk_inner_pt.push_back(itTrack->innerMomentum().rho());
2659  trk_outer_px.push_back(itTrack->outerMomentum().x());
2660  trk_outer_py.push_back(itTrack->outerMomentum().y());
2661  trk_outer_pz.push_back(itTrack->outerMomentum().z());
2662  trk_outer_pt.push_back(itTrack->outerMomentum().rho());
2663  trk_eta .push_back(eta);
2664  trk_lambda .push_back(lambda);
2665  trk_cotTheta .push_back(1/tan(M_PI*0.5-lambda));
2666  trk_phi .push_back(phi);
2667  trk_dxy .push_back(itTrack->dxy(bs.position()));
2668  trk_dz .push_back(itTrack->dz(bs.position()));
2669  trk_ptErr .push_back(itTrack->ptError());
2670  trk_etaErr .push_back(itTrack->etaError());
2671  trk_lambdaErr.push_back(itTrack->lambdaError());
2672  trk_phiErr .push_back(itTrack->phiError());
2673  trk_dxyErr .push_back(itTrack->dxyError());
2674  trk_dzErr .push_back(itTrack->dzError());
2675  trk_refpoint_x.push_back(itTrack->vx());
2676  trk_refpoint_y.push_back(itTrack->vy());
2677  trk_refpoint_z.push_back(itTrack->vz());
2678  trk_nChi2 .push_back( itTrack->normalizedChi2());
2679  trk_shareFrac.push_back(sharedFraction);
2680  trk_q .push_back(charge);
2681  trk_nValid .push_back(hp.numberOfValidHits());
2682  trk_nInvalid .push_back(hp.numberOfLostHits(reco::HitPattern::TRACK_HITS));
2683  trk_nPixel .push_back(hp.numberOfValidPixelHits());
2684  trk_nStrip .push_back(hp.numberOfValidStripHits());
2685  trk_nPixelLay.push_back(hp.pixelLayersWithMeasurement());
2686  trk_nStripLay.push_back(hp.stripLayersWithMeasurement());
2688  trk_nOuterLost.push_back(hp.numberOfLostTrackerHits(reco::HitPattern::MISSING_OUTER_HITS));
2689  trk_nInnerLost.push_back(hp.numberOfLostTrackerHits(reco::HitPattern::MISSING_INNER_HITS));
2690  trk_algo .push_back(itTrack->algo());
2691  trk_originalAlgo.push_back(itTrack->originalAlgo());
2692  trk_algoMask .push_back(itTrack->algoMaskUL());
2693  trk_stopReason.push_back(itTrack->stopReason());
2694  trk_isHP .push_back(itTrack->quality(reco::TrackBase::highPurity));
2695  if(includeSeeds_) {
2696  auto offset = seedCollToOffset.find(itTrack->seedRef().id());
2697  if(offset == seedCollToOffset.end()) {
2698  throw cms::Exception("Configuration") << "Track algo '" << reco::TrackBase::algoName(itTrack->algo())
2699  << "' originalAlgo '" << reco::TrackBase::algoName(itTrack->originalAlgo())
2700  << "' refers to seed collection " << itTrack->seedRef().id()
2701  << ", but that seed collection is not given as an input. The following collections were given as an input " << make_ProductIDMapPrinter(seedCollToOffset);
2702  }
2703 
2704  const auto seedIndex = offset->second + itTrack->seedRef().key();
2705  trk_seedIdx .push_back(seedIndex);
2706  if(see_trkIdx[seedIndex] != -1) {
2707  throw cms::Exception("LogicError") << "Track index has already been set for seed " << seedIndex << " to " << see_trkIdx[seedIndex] << "; was trying to set it to " << iTrack;
2708  }
2709  see_trkIdx[seedIndex] = iTrack;
2710  }
2711  trk_vtxIdx .push_back(-1); // to be set correctly in fillVertices
2712  trk_simTrkIdx.push_back(tpIdx);
2713  LogTrace("TrackingNtuple") << "Track #" << itTrack.key() << " with q=" << charge
2714  << ", pT=" << pt << " GeV, eta: " << eta << ", phi: " << phi
2715  << ", chi2=" << chi2
2716  << ", Nhits=" << nHits
2717  << ", algo=" << itTrack->algoName(itTrack->algo()).c_str()
2718  << " hp=" << itTrack->quality(reco::TrackBase::highPurity)
2719  << " seed#=" << itTrack->seedRef().key()
2720  << " simMatch=" << isSimMatched
2721  << " nSimHits=" << nSimHits
2722  << " sharedFraction=" << (sharedFraction.empty()?-1:sharedFraction[0])
2723  << " tpIdx=" << (tpIdx.empty()?-1:tpIdx[0]);
2724  std::vector<int> hitIdx;
2725  std::vector<int> hitType;
2726 
2727  for(auto i=itTrack->recHitsBegin(); i!=itTrack->recHitsEnd(); i++) {
2728  TransientTrackingRecHit::RecHitPointer hit=theTTRHBuilder.build(&**i );
2729  DetId hitId = hit->geographicalId();
2730  LogTrace("TrackingNtuple") << "hit #" << std::distance(itTrack->recHitsBegin(), i) << " subdet=" << hitId.subdetId();
2731  if(hitId.det() != DetId::Tracker)
2732  continue;
2733 
2734  LogTrace("TrackingNtuple") << " " << subdetstring(hitId.subdetId()) << " " << tTopo.layer(hitId);
2735 
2736  if (hit->isValid()) {
2737  //ugly... but works
2738  const BaseTrackerRecHit* bhit = dynamic_cast<const BaseTrackerRecHit*>(&*hit);
2739  const auto& clusterRef = bhit->firstClusterRef();
2740  unsigned int clusterKey;
2741  if(clusterRef.isPixel()){
2742  clusterKey = clusterRef.cluster_pixel().key();
2743  } else if(clusterRef.isPhase2()){
2744  clusterKey = clusterRef.cluster_phase2OT().key();
2745  } else {
2746  clusterKey = clusterRef.cluster_strip().key();
2747  }
2748 
2749  LogTrace("TrackingNtuple") << " id: " << hitId.rawId() << " - globalPos =" << hit->globalPosition()
2750  << " cluster=" << clusterKey
2751  << " clusterRef ID=" << clusterRef.id()
2752  << " eta,phi: " << hit->globalPosition().eta() << "," << hit->globalPosition().phi();
2753  if(includeAllHits_) {
2754  checkProductID(hitProductIds, clusterRef.id(), "track");
2755  if(clusterRef.isPixel()){
2756  pix_trkIdx[clusterKey].push_back(iTrack);
2757  } else if(clusterRef.isPhase2()){
2758  ph2_trkIdx[clusterKey].push_back(iTrack);
2759  } else {
2760  str_trkIdx[clusterKey].push_back(iTrack);
2761  }
2762 
2763  }
2764 
2765  hitIdx.push_back(clusterKey);
2766  if(clusterRef.isPixel()){
2767  hitType.push_back( static_cast<int>(HitType::Pixel));
2768  } else if(clusterRef.isPhase2()){
2769  hitType.push_back( static_cast<int>(HitType::Phase2OT));
2770  } else {
2771  hitType.push_back( static_cast<int>(HitType::Strip));
2772  }
2773  } else {
2774  LogTrace("TrackingNtuple") << " - invalid hit";
2775 
2776  hitIdx.push_back( inv_isBarrel.size() );
2777  hitType.push_back( static_cast<int>(HitType::Invalid) );
2778 
2779  inv_isBarrel.push_back( hitId.subdetId()==1 );
2780  if(includeStripHits_) inv_detId.push_back( tTopo, hitId );
2781  else inv_detId_phase2.push_back( tTopo, hitId );
2782  inv_type .push_back( hit->getType() );
2783 
2784  }
2785  }
2786 
2787  trk_hitIdx.push_back(hitIdx);
2788  trk_hitType.push_back(hitType);
2789  }
2790 }
2791 
2792 
2794  const edm::RefToBaseVector<reco::Track>& tracks,
2795  const reco::BeamSpot& bs,
2796  const TrackingParticleRefVector& tpCollection,
2797  const TrackingVertexRefKeyToIndex& tvKeyToIndex,
2798  const reco::TrackToTrackingParticleAssociator& associatorByHits,
2799  const std::vector<TPHitIndex>& tpHitList
2800  ) {
2801  edm::ESHandle<ParametersDefinerForTP> parametersDefinerH;
2802  iSetup.get<TrackAssociatorRecord>().get(parametersDefinerName_, parametersDefinerH);
2803  const ParametersDefinerForTP *parametersDefiner = parametersDefinerH.product();
2804 
2805  // Number of 3D layers for TPs
2807  iEvent.getByToken(tpNLayersToken_, tpNLayersH);
2808  const auto& nLayers_tPCeff = *tpNLayersH;
2809 
2810  iEvent.getByToken(tpNPixelLayersToken_, tpNLayersH);
2811  const auto& nPixelLayers_tPCeff = *tpNLayersH;
2812 
2813  iEvent.getByToken(tpNStripStereoLayersToken_, tpNLayersH);
2814  const auto& nStripMonoAndStereoLayers_tPCeff = *tpNLayersH;
2815 
2816  reco::SimToRecoCollection simRecColl = associatorByHits.associateSimToReco(tracks, tpCollection);
2817 
2818  for(const TrackingParticleRef& tp: tpCollection) {
2819  LogTrace("TrackingNtuple") << "tracking particle pt=" << tp->pt() << " eta=" << tp->eta() << " phi=" << tp->phi();
2820  bool isRecoMatched = false;
2821  std::vector<int> tkIdx;
2822  std::vector<float> sharedFraction;
2823  auto foundTracks = simRecColl.find(tp);
2824  if(foundTracks != simRecColl.end()) {
2825  isRecoMatched = true;
2826  for(const auto trackQuality: foundTracks->val) {
2827  sharedFraction.push_back(trackQuality.second);
2828  tkIdx.push_back(trackQuality.first.key());
2829  }
2830  }
2831 
2832  sim_genPdgIds.emplace_back();
2833  for(const auto& genRef: tp->genParticles()) {
2834  if(genRef.isNonnull())
2835  sim_genPdgIds.back().push_back(genRef->pdgId());
2836  }
2837 
2838  bool isFromBHadron = false;
2839  // Logic is similar to SimTracker/TrackHistory
2840  if(tracer_.evaluate(tp)) { // ignore TP if history can not be traced
2841  // following is from TrackClassifier::processesAtGenerator()
2842  HistoryBase::RecoGenParticleTrail const & recoGenParticleTrail = tracer_.recoGenParticleTrail();
2843  for(const auto& particle: recoGenParticleTrail) {
2844  HepPDT::ParticleID particleID(particle->pdgId());
2845  if(particleID.hasBottom()) {
2846  isFromBHadron = true;
2847  break;
2848  }
2849  }
2850  }
2851 
2852  LogTrace("TrackingNtuple") << "matched to tracks = " << make_VectorPrinter(tkIdx) << " isRecoMatched=" << isRecoMatched;
2853  sim_event .push_back(tp->eventId().event());
2854  sim_bunchCrossing.push_back(tp->eventId().bunchCrossing());
2855  sim_pdgId .push_back(tp->pdgId());
2856  sim_isFromBHadron.push_back(isFromBHadron);
2857  sim_px .push_back(tp->px());
2858  sim_py .push_back(tp->py());
2859  sim_pz .push_back(tp->pz());
2860  sim_pt .push_back(tp->pt());
2861  sim_eta .push_back(tp->eta());
2862  sim_phi .push_back(tp->phi());
2863  sim_q .push_back(tp->charge());
2864  sim_trkIdx .push_back(tkIdx);
2865  sim_shareFrac.push_back(sharedFraction);
2866  sim_parentVtxIdx.push_back( tvKeyToIndex.at(tp->parentVertex().key()) );
2867  std::vector<int> decayIdx;
2868  for(const auto& v: tp->decayVertices())
2869  decayIdx.push_back( tvKeyToIndex.at(v.key()) );
2870  sim_decayVtxIdx.push_back(decayIdx);
2871 
2872  //Calcualte the impact parameters w.r.t. PCA
2873  TrackingParticle::Vector momentum = parametersDefiner->momentum(iEvent,iSetup,tp);
2874  TrackingParticle::Point vertex = parametersDefiner->vertex(iEvent,iSetup,tp);
2875  auto dxySim = TrackingParticleIP::dxy(vertex, momentum, bs.position());
2876  auto dzSim = TrackingParticleIP::dz(vertex, momentum, bs.position());
2877  const double lambdaSim = M_PI/2 - momentum.theta();
2878  sim_pca_pt .push_back(std::sqrt(momentum.perp2()));
2879  sim_pca_eta .push_back(momentum.Eta());
2880  sim_pca_lambda .push_back(lambdaSim);
2881  sim_pca_cotTheta .push_back(1/tan(M_PI*0.5-lambdaSim));
2882  sim_pca_phi .push_back(momentum.phi());
2883  sim_pca_dxy .push_back(dxySim);
2884  sim_pca_dz .push_back(dzSim);
2885 
2886  std::vector<int> hitIdx;
2887  int nPixel=0, nStrip=0;
2888  auto rangeHit = std::equal_range(tpHitList.begin(), tpHitList.end(), TPHitIndex(tp.key()), tpHitIndexListLess);
2889  for(auto ip = rangeHit.first; ip != rangeHit.second; ++ip) {
2890  auto type = HitType::Unknown;
2891  if(!simhit_hitType[ip->simHitIdx].empty())
2892  type = static_cast<HitType>(simhit_hitType[ip->simHitIdx][0]);
2893  LogTrace("TrackingNtuple") << "simhit=" << ip->simHitIdx << " type=" << static_cast<int>(type);
2894  hitIdx.push_back(ip->simHitIdx);
2895  const auto detid = DetId(includeStripHits_ ? simhit_detId[ip->simHitIdx] : simhit_detId_phase2[ip->simHitIdx]);
2896  if(detid.det() != DetId::Tracker) {
2897  throw cms::Exception("LogicError") << "Encountered SimHit for TP " << tp.key() << " with DetId " << detid.rawId() << " whose det() is not Tracker but " << detid.det();
2898  }
2899  const auto subdet = detid.subdetId();
2900  switch(subdet) {
2903  ++nPixel;
2904  break;
2905  case StripSubdetector::TIB:
2906  case StripSubdetector::TID:
2907  case StripSubdetector::TOB:
2908  case StripSubdetector::TEC:
2909  ++nStrip;
2910  break;
2911  default:
2912  throw cms::Exception("LogicError") << "Encountered SimHit for TP " << tp.key() << " with DetId " << detid.rawId() << " whose subdet is not recognized, is " << subdet;
2913  };
2914  }
2915  sim_nValid .push_back( hitIdx.size() );
2916  sim_nPixel .push_back( nPixel );
2917  sim_nStrip .push_back( nStrip );
2918 
2919  const auto nSimLayers = nLayers_tPCeff[tp];
2920  const auto nSimPixelLayers = nPixelLayers_tPCeff[tp];
2921  const auto nSimStripMonoAndStereoLayers = nStripMonoAndStereoLayers_tPCeff[tp];
2922  sim_nLay .push_back( nSimLayers );
2923  sim_nPixelLay.push_back( nSimPixelLayers );
2924  sim_n3DLay .push_back( nSimPixelLayers+nSimStripMonoAndStereoLayers );
2925 
2926  sim_simHitIdx.push_back(hitIdx);
2927  }
2928 }
2929 
2930 // called from fillSeeds
2932  const reco::SimToRecoCollection& simRecColl,
2933  const TrackingParticleRefKeyToIndex& tpKeyToIndex,
2934  const unsigned int seedOffset) {
2935  if(sim_seedIdx.empty()) // first call
2936  sim_seedIdx.resize(tpCollection.size());
2937 
2938  for(const auto& keyVal: simRecColl) {
2939  const auto& tpRef = keyVal.key;
2940  auto found = tpKeyToIndex.find(tpRef.key());
2941  if(found == tpKeyToIndex.end())
2942  throw cms::Exception("Assert") << __FILE__ << ":" << __LINE__ << " fillTrackingParticlesForSeeds: tpRef.key() " << tpRef.key() << " not found from tpKeyToIndex. tpKeyToIndex size " << tpKeyToIndex.size();
2943  const auto tpIndex = found->second;
2944  for(const auto& pair: keyVal.val) {
2945  const auto& seedRef = pair.first->seedRef();
2946  sim_seedIdx[tpIndex].push_back(seedOffset + seedRef.key());
2947  }
2948  }
2949 }
2950 
2951 
2953  const edm::RefToBaseVector<reco::Track>& tracks) {
2954  for(size_t iVertex=0, size=vertices.size(); iVertex<size; ++iVertex) {
2955  const reco::Vertex& vertex = vertices[iVertex];
2956  vtx_x.push_back(vertex.x());
2957  vtx_y.push_back(vertex.y());
2958  vtx_z.push_back(vertex.z());
2959  vtx_xErr.push_back(vertex.xError());
2960  vtx_yErr.push_back(vertex.yError());
2961  vtx_zErr.push_back(vertex.zError());
2962  vtx_chi2.push_back(vertex.chi2());
2963  vtx_ndof.push_back(vertex.ndof());
2964  vtx_fake.push_back(vertex.isFake());
2965  vtx_valid.push_back(vertex.isValid());
2966 
2967  std::vector<int> trkIdx;
2968  for(auto iTrack = vertex.tracks_begin(); iTrack != vertex.tracks_end(); ++iTrack) {
2969  // Ignore link if vertex was fit from a track collection different from the input
2970  if(iTrack->id() != tracks.id())
2971  continue;
2972 
2973  trkIdx.push_back(iTrack->key());
2974 
2975  if(trk_vtxIdx[iTrack->key()] != -1) {
2976  throw cms::Exception("LogicError") << "Vertex index has already been set for track " << iTrack->key() << " to " << trk_vtxIdx[iTrack->key()] << "; was trying to set it to " << iVertex;
2977  }
2978  trk_vtxIdx[iTrack->key()] = iVertex;
2979  }
2980  vtx_trkIdx.push_back(trkIdx);
2981  }
2982 }
2983 
2985  const TrackingParticleRefKeyToIndex& tpKeyToIndex
2986  ) {
2987  int current_event = -1;
2988  for(const auto& ref: trackingVertices) {
2989  const TrackingVertex v = *ref;
2990  if(v.eventId().event() != current_event) {
2991  // next PV
2992  current_event = v.eventId().event();
2993  simpv_idx.push_back(simvtx_x.size());
2994  }
2995 
2996  unsigned int processType = std::numeric_limits<unsigned int>::max();
2997  if(!v.g4Vertices().empty()) {
2998  processType = v.g4Vertices()[0].processType();
2999  }
3000 
3001  simvtx_event.push_back(v.eventId().event());
3002  simvtx_bunchCrossing.push_back(v.eventId().bunchCrossing());
3003  simvtx_processType.push_back(processType);
3004 
3005  simvtx_x.push_back(v.position().x());
3006  simvtx_y.push_back(v.position().y());
3007  simvtx_z.push_back(v.position().z());
3008 
3009  auto fill = [&](const TrackingParticleRefVector& tps, std::vector<int>& idx) {
3010  for(const auto& tpRef: tps) {
3011  auto found = tpKeyToIndex.find(tpRef.key());
3012  if(found != tpKeyToIndex.end()) {
3013  idx.push_back(found->second);
3014  }
3015  }
3016  };
3017 
3018  std::vector<int> sourceIdx;
3019  std::vector<int> daughterIdx;
3020  fill(v.sourceTracks(), sourceIdx);
3021  fill(v.daughterTracks(), daughterIdx);
3022 
3023  simvtx_sourceSimIdx.push_back(sourceIdx);
3024  simvtx_daughterSimIdx.push_back(daughterIdx);
3025  }
3026 }
3027 
3028 // ------------ method fills 'descriptions' with the allowed parameters for the module ------------
3030  //The following says we do not know what parameters are allowed so do no validation
3031  // Please change this to state exactly what you do use, even if it is no parameters
3033  desc.addUntracked<std::vector<edm::InputTag> >("seedTracks", std::vector<edm::InputTag>{
3034  edm::InputTag("seedTracksinitialStepSeeds"),
3035  edm::InputTag("seedTracksdetachedTripletStepSeeds"),
3036  edm::InputTag("seedTrackspixelPairStepSeeds"),
3037  edm::InputTag("seedTrackslowPtTripletStepSeeds"),
3038  edm::InputTag("seedTracksmixedTripletStepSeeds"),
3039  edm::InputTag("seedTrackspixelLessStepSeeds"),
3040  edm::InputTag("seedTrackstobTecStepSeeds"),
3041  edm::InputTag("seedTracksjetCoreRegionalStepSeeds"),
3042  edm::InputTag("seedTracksmuonSeededSeedsInOut"),
3043  edm::InputTag("seedTracksmuonSeededSeedsOutIn")
3044  });
3045  desc.addUntracked<std::vector<edm::InputTag> >("trackCandidates", std::vector<edm::InputTag>{
3046  edm::InputTag("initialStepTrackCandidates"),
3047  edm::InputTag("detachedTripletStepTrackCandidates"),
3048  edm::InputTag("pixelPairStepTrackCandidates"),
3049  edm::InputTag("lowPtTripletStepTrackCandidates"),
3050  edm::InputTag("mixedTripletStepTrackCandidates"),
3051  edm::InputTag("pixelLessStepTrackCandidates"),
3052  edm::InputTag("tobTecStepTrackCandidates"),
3053  edm::InputTag("jetCoreRegionalStepTrackCandidates"),
3054  edm::InputTag("muonSeededTrackCandidatesInOut"),
3055  edm::InputTag("muonSeededTrackCandidatesOutIn")
3056  });
3057  desc.addUntracked<edm::InputTag>("tracks", edm::InputTag("generalTracks"));
3058  desc.addUntracked<edm::InputTag>("trackingParticles", edm::InputTag("mix", "MergedTrackTruth"));
3059  desc.addUntracked<bool>("trackingParticlesRef", false);
3060  desc.addUntracked<edm::InputTag>("clusterTPMap", edm::InputTag("tpClusterProducer"));
3061  desc.addUntracked<edm::InputTag>("simHitTPMap", edm::InputTag("simHitTPAssocProducer"));
3062  desc.addUntracked<edm::InputTag>("trackAssociator", edm::InputTag("quickTrackAssociatorByHits"));
3063  desc.addUntracked<edm::InputTag>("pixelDigiSimLink", edm::InputTag("simSiPixelDigis"));
3064  desc.addUntracked<edm::InputTag>("stripDigiSimLink", edm::InputTag("simSiStripDigis"));
3065  desc.addUntracked<edm::InputTag>("phase2OTSimLink", edm::InputTag(""));
3066  desc.addUntracked<edm::InputTag>("beamSpot", edm::InputTag("offlineBeamSpot"));
3067  desc.addUntracked<edm::InputTag>("pixelRecHits", edm::InputTag("siPixelRecHits"));
3068  desc.addUntracked<edm::InputTag>("stripRphiRecHits", edm::InputTag("siStripMatchedRecHits", "rphiRecHit"));
3069  desc.addUntracked<edm::InputTag>("stripStereoRecHits", edm::InputTag("siStripMatchedRecHits", "stereoRecHit"));
3070  desc.addUntracked<edm::InputTag>("stripMatchedRecHits", edm::InputTag("siStripMatchedRecHits", "matchedRecHit"));
3071  desc.addUntracked<edm::InputTag>("phase2OTRecHits", edm::InputTag("siPhase2RecHits"));
3072  desc.addUntracked<edm::InputTag>("vertices", edm::InputTag("offlinePrimaryVertices"));
3073  desc.addUntracked<edm::InputTag>("trackingVertices", edm::InputTag("mix", "MergedTrackTruth"));
3074  desc.addUntracked<edm::InputTag>("trackingParticleNlayers", edm::InputTag("trackingParticleNumberOfLayersProducer", "trackerLayers"));
3075  desc.addUntracked<edm::InputTag>("trackingParticleNpixellayers", edm::InputTag("trackingParticleNumberOfLayersProducer", "pixelLayers"));
3076  desc.addUntracked<edm::InputTag>("trackingParticleNstripstereolayers", edm::InputTag("trackingParticleNumberOfLayersProducer", "stripStereoLayers"));
3077  desc.addUntracked<std::string>("TTRHBuilder", "WithTrackAngle");
3078  desc.addUntracked<std::string>("parametersDefiner", "LhcParametersDefinerForTP");
3079  desc.addUntracked<bool>("includeSeeds", false);
3080  desc.addUntracked<bool>("includeAllHits", false);
3081  descriptions.add("trackingNtuple",desc);
3082 }
3083 
3084 //define this as a plug-in
#define LogDebug(id)
int adc(sample_type sample)
get the ADC sample (12 bits)
RunNumber_t run() const
Definition: EventID.h:39
size
Write out results.
std::vector< float > sim_pca_dz
edm::LuminosityBlockNumber_t ev_lumi
static const std::string kSharedResource
Definition: TFileService.h:76
std::vector< unsigned int > simvtx_processType
Parsed parse(const TrackerTopology &tTopo, const DetId &id) const
edm::EDGetTokenT< TrackingParticleRefVector > trackingParticleRefToken_
std::vector< unsigned int > sim_nLay
type
Definition: HCALResponse.h:21
std::vector< float > ph2_radL
EventNumber_t event() const
Definition: EventID.h:41
Map map_
unsigned int size_type
Definition: View.h:90
void fillTrackingVertices(const TrackingVertexRefVector &trackingVertices, const TrackingParticleRefKeyToIndex &tpKeyToIndex)
const TrackerGeomDet * idToDetUnit(DetId) const
Return the pointer to the GeomDetUnit corresponding to a given DetId.
edm::EDGetTokenT< SiStripMatchedRecHit2DCollection > stripMatchedRecHitToken_
T getUntrackedParameter(std::string const &, T const &) const
std::vector< short > see_fitok
Phase2Cluster1DRef cluster_phase2OT() const
std::vector< short > vtx_fake
std::vector< float > simvtx_z
std::vector< std::vector< int > > see_hitType
edm::EDGetTokenT< SiStripRecHit2DCollection > stripRphiRecHitToken_
Phase2TrackerCluster1D const & phase2OTCluster() const
const TrackingParticleRefVector & sourceTracks() const
std::vector< short > ph2_isBarrel
bool tecIsDoubleSide(const DetId &id) const
TrackAssociatorByHitsImpl::SimHitTPAssociationList SimHitTPAssociationList
DetIdStrip str_detId
std::vector< float > trk_phi
SiPixelCluster const & pixelCluster() const
std::vector< float > sim_pca_cotTheta
bool tobIsDoubleSide(const DetId &id) const
const_iterator end(bool update=false) const
std::vector< float > sim_pca_dxy
void book(const std::string &prefix, TTree *tree)
std::vector< float > see_stateTrajX
std::vector< unsigned int > trk_nOuterLost
size_type dataSize() const
std::vector< float > glu_xy
std::vector< std::vector< int > > ph2_seeIdx
std::vector< float > glu_radL
std::vector< float > trk_inner_pz
int event() const
get the contents of the subdetector field (should be protected?)
std::vector< float > see_stateTrajPy
std::vector< float > pix_y
std::vector< int > trk_vtxIdx
std::vector< std::vector< int > > str_trkIdx
std::vector< unsigned int > see_nValid
std::vector< float > str_yy
iterator find(det_id_type id)
Definition: DetSetVector.h:290
bool tibIsDoubleSide(const DetId &id) const
bool trackFromSeedFitFailed(const reco::Track &track)
std::vector< float > trk_outer_py
std::unordered_map< reco::RecoToSimCollection::index_type, size_t > TrackingParticleRefKeyToIndex
unsigned int tibString(const DetId &id) const
std::vector< float > pix_zz
unsigned int tidRing(const DetId &id) const
std::vector< unsigned short > layer
ParameterDescriptionBase * addUntracked(U const &iLabel, T const &value)
std::vector< float > ph2_bbxi
std::vector< int > glu_monoIdx
std::vector< float > trk_eta
module()
Definition: vlib.cc:994
std::vector< short > glu_isBarrel
std::vector< unsigned short > order
std::vector< int > sim_bunchCrossing
SimHitData matchCluster(const OmniClusterRef &cluster, DetId hitId, int clusterKey, const TransientTrackingRecHit::RecHitPointer &ttrh, const ClusterTPAssociation &clusterToTPMap, const TrackingParticleRefKeyToIndex &tpKeyToIndex, const SimHitTPAssociationProducer::SimHitTPAssociationList &simHitsTPAssoc, const edm::DetSetVector< SimLink > &digiSimLinks, const SimHitRefKeyToIndex &simHitRefKeyToIndex, HitType hitType)
std::vector< float > see_phiErr
void fillStripMatchedHits(const edm::Event &iEvent, const TransientTrackingRecHitBuilder &theTTRHBuilder, const TrackerTopology &tTopo, std::vector< std::pair< int, int > > &monoStereoClusterList)
trackRef_iterator tracks_end() const
last iterator over tracks
Definition: Vertex.cc:81
std::vector< std::vector< int > > simhit_hitIdx
static bool simHitTPAssociationListGreater(SimHitTPPair i, SimHitTPPair j)
const_iterator end() const
last iterator over the map (read only)
std::vector< float > str_x
std::vector< float > see_dzErr
std::vector< unsigned int > sim_n3DLay
std::vector< float > trk_cotTheta
CombineDetId< DetIdCommon, DetIdOTCommon, DetIdStripOnly > DetIdStrip
bool getByToken(EDGetToken token, Handle< PROD > &result) const
Definition: Event.h:457
std::vector< unsigned int > see_nStrip
def analyze(function, filename, filter=None)
Definition: Profiling.py:11
std::vector< float > trk_px
double zError() const
error on z
Definition: Vertex.h:123
void fillPixelHits(const edm::Event &iEvent, const ClusterTPAssociation &clusterToTPMap, const TrackingParticleRefKeyToIndex &tpKeyToIndex, const SimHitTPAssociationProducer::SimHitTPAssociationList &simHitsTPAssoc, const edm::DetSetVector< PixelDigiSimLink > &digiSimLink, const TransientTrackingRecHitBuilder &theTTRHBuilder, const TrackerTopology &tTopo, const SimHitRefKeyToIndex &simHitRefKeyToIndex, std::set< edm::ProductID > &hitProductIds)
std::vector< unsigned short > pix_simType
std::vector< unsigned short > inv_type
std::vector< float > see_stateTrajPz
std::vector< float > pix_zx
TPHitIndex(unsigned int tp=0, unsigned int simHit=0, float to=0, unsigned int id=0)
const std::vector< SimVertex > & g4Vertices() const
#define DEFINE_FWK_MODULE(type)
Definition: MakerMacros.h:17
std::vector< float > sim_phi
std::vector< std::vector< int > > trk_simTrkIdx
void fillStripRphiStereoHits(const edm::Event &iEvent, const ClusterTPAssociation &clusterToTPMap, const TrackingParticleRefKeyToIndex &tpKeyToIndex, const SimHitTPAssociationProducer::SimHitTPAssociationList &simHitsTPAssoc, const edm::DetSetVector< StripDigiSimLink > &digiSimLink, const TransientTrackingRecHitBuilder &theTTRHBuilder, const TrackerTopology &tTopo, const SimHitRefKeyToIndex &simHitRefKeyToIndex, std::set< edm::ProductID > &hitProductIds)
int numberOfValidHits() const
Definition: HitPattern.h:823
double y() const
y coordinate
Definition: Vertex.h:113
edm::EDGetTokenT< reco::TrackToTrackingParticleAssociator > trackAssociatorToken_
OmniClusterRef const & stereoClusterRef() const
int pdgId() const
PDG ID.
std::string print(const Track &, edm::Verbosity=edm::Concise)
Track print utility.
Definition: print.cc:10
bool isValid() const
Tells whether the vertex is valid.
Definition: Vertex.h:68
edm::EDGetTokenT< SiStripRecHit2DCollection > stripStereoRecHitToken_
std::vector< float > trk_dxyErr
std::vector< float > str_yz
void push_back(const TrackerTopology &tTopo, const DetId &id)
std::vector< float > trk_pt
unsigned int tecRing(const DetId &id) const
ring id
std::vector< float > glu_x
std::vector< float > trk_inner_py
std::vector< float > see_px
std::vector< float > see_chi2
const_iterator find(const key_type &k) const
find element with specified reference key
std::vector< float > glu_z
std::vector< float > see_stateTrajY
edm::EDGetTokenT< edm::View< reco::Track > > trackToken_
CombineDetId< DetIdCommon, DetIdPixelOnly, DetIdOTCommon, DetIdPhase2OTOnly > DetIdAllPhase2
CombineDetId< DetIdCommon, DetIdPixelOnly > DetIdPixel
unsigned int pxbLadder(const DetId &id) const
Global3DPoint GlobalPoint
Definition: GlobalPoint.h:10
unsigned int side(const DetId &id) const
void fillBeamSpot(const reco::BeamSpot &bs)
std::vector< unsigned short > see_stopReason
std::vector< float > trk_outer_px
void fillTracks(const edm::RefToBaseVector< reco::Track > &tracks, const TrackingParticleRefVector &tpCollection, const TrackingParticleRefKeyToIndex &tpKeyToIndex, const reco::BeamSpot &bs, const reco::TrackToTrackingParticleAssociator &associatorByHits, const TransientTrackingRecHitBuilder &theTTRHBuilder, const TrackerTopology &tTopo, const std::set< edm::ProductID > &hitProductIds, const std::map< edm::ProductID, size_t > &seedToCollIndex)
std::vector< std::vector< int > > trk_hitType
DetIdPixel pix_detId
std::vector< float > ph2_xx
TrackingParticleRefKeyToIndex TrackingVertexRefKeyToIndex
unsigned long long EventNumber_t
std::vector< std::vector< int > > ph2_trkIdx
int numberOfValidStripHits() const
Definition: HitPattern.h:853
#define BOOK(name)
edm::EDGetTokenT< Phase2TrackerRecHit1DCollectionNew > phase2OTRecHitToken_
bool isStereo(const DetId &id) const
size_type size() const
std::vector< unsigned int > see_algo
std::vector< Vertex > VertexCollection
collection of Vertex objects
Definition: VertexFwd.h:9
T * make(const Args &...args) const
make new ROOT object
Definition: TFileService.h:64
std::vector< float > trk_inner_pt
uint16_t firstStrip() const
std::vector< short > simhit_process
std::vector< unsigned short > module
std::pair< TrackPSimHitRef::key_type, edm::ProductID > SimHitFullKey
CombineDetId< DetIdCommon, DetIdOTCommon, DetIdPhase2OTOnly > DetIdPhase2OT
std::vector< std::vector< int > > str_seeIdx
std::vector< std::vector< int > > see_simTrkIdx
std::vector< int > simvtx_event
std::vector< float > str_radL
std::vector< int > simhit_simTrkIdx
key_type key() const
Accessor for product key.
Definition: Ref.h:264
std::vector< std::vector< float > > sim_shareFrac
std::vector< unsigned short > trk_stopReason
int pixelLayersWithMeasurement() const
Definition: HitPattern.cc:499
std::vector< unsigned short > ladder
static bool tpHitIndexListLess(const TPHitIndex &i, const TPHitIndex &j)
TrackingNtuple(const edm::ParameterSet &)
auto vector_transform(std::vector< InputType > const &input, Function predicate) -> std::vector< typename std::remove_cv< typename std::remove_reference< decltype(predicate(input.front()))>::type >::type >
Definition: transform.h:11
std::ostream & operator<<(std::ostream &out, const ALILine &li)
Definition: ALILine.cc:188
std::vector< float > sim_py
void find(edm::Handle< EcalRecHitCollection > &hits, DetId thisDet, std::vector< EcalRecHitCollection::const_iterator > &hit, bool debug=false)
Definition: FindCaloHit.cc:20
LuminosityBlockNumber_t luminosityBlock() const
Definition: EventID.h:40
std::vector< float > sim_px
unsigned int LuminosityBlockNumber_t
std::vector< float > pix_xx
std::vector< std::vector< int > > sim_decayVtxIdx
std::vector< float > trk_refpoint_x
std::vector< float > pix_radL
std::vector< float > pix_bbxi
void fillPhase2OTHits(const edm::Event &iEvent, const ClusterTPAssociation &clusterToTPMap, const TrackingParticleRefKeyToIndex &tpKeyToIndex, const SimHitTPAssociationProducer::SimHitTPAssociationList &simHitsTPAssoc, const edm::DetSetVector< PixelDigiSimLink > &digiSimLink, const TransientTrackingRecHitBuilder &theTTRHBuilder, const TrackerTopology &tTopo, const SimHitRefKeyToIndex &simHitRefKeyToIndex, std::set< edm::ProductID > &hitProductIds)
std::vector< float > ph2_zx
ProductID id() const
Accessor for product ID.
Definition: Ref.h:258
std::vector< int > simpv_idx
edm::EDGetTokenT< edm::DetSetVector< PixelDigiSimLink > > pixelSimLinkToken_
CombineDetId< DetIdCommon, DetIdPixelOnly, DetIdOTCommon, DetIdStripOnly > DetIdAll
std::vector< std::vector< int > > pix_seeIdx
int numberOfLostTrackerHits(HitCategory category) const
Definition: HitPattern.h:907
std::vector< unsigned short > str_simType
ClusterPixelRef cluster_pixel() const
std::vector< int > sim_q
std::vector< short > inv_isBarrel
uint32_t rawId() const
get the raw id
Definition: DetId.h:43
std::vector< unsigned short > ring
RefToBase< value_type > refAt(size_type i) const
bool isLower(const DetId &id) const
math::XYZPointD Point
point in the space
std::vector< float > see_etaErr
std::vector< float > simhit_z
std::vector< float > ph2_z
std::vector< float > ph2_yy
Parsed parse(const TrackerTopology &tTopo, const DetId &id) const
std::vector< float > trk_refpoint_y
unsigned int module(const DetId &id) const
std::vector< int > sim_event
std::vector< unsigned int > trk_nStrip
DetIdAll simhit_detId
SiStripCluster const & stripCluster() const
std::vector< const reco::GenParticle * > RecoGenParticleTrail
reco::GenParticle trail type.
Definition: HistoryBase.h:21
std::vector< float > chargeFraction
edm::EDGetTokenT< edm::ValueMap< unsigned int > > tpNStripStereoLayersToken_
unsigned int tibSide(const DetId &id) const
std::string parametersDefinerName_
std::vector< unsigned int > trk_nPixel
std::vector< float > glu_y
void fillTrackingParticles(const edm::Event &iEvent, const edm::EventSetup &iSetup, const edm::RefToBaseVector< reco::Track > &tracks, const reco::BeamSpot &bs, const TrackingParticleRefVector &tpCollection, const TrackingVertexRefKeyToIndex &tvKeyToIndex, const reco::TrackToTrackingParticleAssociator &associatorByHits, const std::vector< TPHitIndex > &tpHitList)
std::vector< unsigned short > panel
std::vector< float > trk_pz
int iEvent
Definition: GenABIO.cc:230
std::vector< float > trk_dzErr
std::vector< unsigned short > isStereo
std::vector< float > trk_lambdaErr
std::vector< unsigned short > isUpper
int numberOfValidStripLayersWithMonoAndStereo(uint16_t stripdet, uint16_t layer) const
Definition: HitPattern.cc:341
edm::EDGetTokenT< SiPixelRecHitCollection > pixelRecHitToken_
std::vector< float > ph2_y
bool isNotFinite(T x)
Definition: isFinite.h:10
std::vector< std::vector< int > > simvtx_sourceSimIdx
std::vector< float > trk_etaErr
std::vector< short > pix_isBarrel
edm::EDGetTokenT< edm::DetSetVector< PixelDigiSimLink > > siphase2OTSimLinksToken_
std::vector< float > glu_yz
std::vector< float > sim_pca_phi
auto dz(const T_Vertex &vertex, const T_Momentum &momentum, const T_Point &point)
std::vector< unsigned int > trk_algo
simTrack
per collection params
void fillTrackingParticlesForSeeds(const TrackingParticleRefVector &tpCollection, const reco::SimToRecoCollection &simRecColl, const TrackingParticleRefKeyToIndex &tpKeyToIndex, const unsigned int seedOffset)
susybsm::HSCParticleRefProd hp
Definition: classes.h:27
std::vector< float > ph2_xy
T sqrt(T t)
Definition: SSEVec.h:18
std::vector< float > vtx_y
std::vector< float > pix_z
void clear(CLHEP::HepGenMatrix &m)
Helper function: Reset all elements of a matrix to 0.
Definition: matutil.cc:167
int bunchCrossing() const
get the detector field from this detid
std::vector< int > bunchCrossing
std::vector< float > sim_eta
std::vector< unsigned short > blade
std::vector< unsigned int > trk_originalAlgo
std::vector< unsigned int > trk_nInnerLost
std::vector< float > str_y
std::vector< int > sim_pdgId
std::vector< int > see_q
std::vector< std::vector< int > > simhit_hitType
std::vector< float > trk_refpoint_z
unsigned int tobSide(const DetId &id) const
std::vector< edm::EDGetTokenT< edm::View< reco::Track > > > seedTokens_
edm::EDGetTokenT< SimHitTPAssociationProducer::SimHitTPAssociationList > simHitTPMapToken_
std::vector< float > pix_yz
std::vector< std::vector< int > > sim_genPdgIds
std::vector< int > trk_seedIdx
std::vector< std::vector< float > > pix_chargeFraction
edm::RunNumber_t ev_run
std::vector< float > vtx_yErr
std::vector< std::vector< int > > pix_trkIdx
Tan< T >::type tan(const T &t)
Definition: Tan.h:22
Abs< T >::type abs(const T &t)
Definition: Abs.h:22
std::vector< unsigned int > sim_nValid
std::vector< float > glu_yy
std::vector< float > vtx_ndof
double chi2() const
chi-squares
Definition: Vertex.h:98
std::vector< std::vector< int > > ph2_simHitIdx
std::vector< float > simvtx_x
double z() const
z coordinate
Definition: Vertex.h:115
T operator[](int i) const
virtual TrackingParticle::Vector momentum(const edm::Event &iEvent, const edm::EventSetup &iSetup, const Charge ch, const Point &vtx, const LorentzVector &lv) const
std::vector< float > str_zz
DetIdAllPhase2 inv_detId_phase2
std::vector< float > sim_pca_pt
DetIdPhase2OT ph2_detId
std::vector< float > see_dxyErr
bool isMatched(TrackingRecHit const &hit)
double BeamWidthX() const
beam width X
Definition: BeamSpot.h:86
range equal_range(const OmniClusterRef &key) const
std::vector< float > see_pt
std::vector< unsigned int > see_nPhase2OT
std::vector< edm::EDGetTokenT< std::vector< short > > > seedStopReasonTokens_
edm::EDGetTokenT< TrackingVertexCollection > trackingVertexToken_
std::vector< float > see_dxy
std::vector< std::vector< int > > glu_seeIdx
std::vector< unsigned int > trk_n3DLay
std::vector< std::vector< int > > sim_trkIdx
Definition: Types.py:1
std::vector< float > trk_outer_pt
#define end
Definition: vmac.h:37
static bool tpHitIndexListLessSort(const TPHitIndex &i, const TPHitIndex &j)
std::vector< int > matchingSimHit
T min(T a, T b)
Definition: MathUtil.h:58
const bool includeSeeds_
size_type size() const
std::vector< float > trk_dz
std::vector< float > trk_ptErr
std::vector< unsigned int > trk_nStripLay
void fillSimHits(const TrackerGeometry &tracker, const TrackingParticleRefKeyToIndex &tpKeyToIndex, const SimHitTPAssociationProducer::SimHitTPAssociationList &simHitsTPAssoc, const TrackerTopology &tTopo, SimHitRefKeyToIndex &simHitRefKeyToIndex, std::vector< TPHitIndex > &tpHitList)
std::vector< float > see_phi
OmniClusterRef const & monoClusterRef() const
std::vector< float > vtx_z
int subdetId() const
get the contents of the subdetector field (not cast into any detector&#39;s numbering enum) ...
Definition: DetId.h:37
char const * module
Definition: ProductLabels.h:5
std::vector< float > see_pz
void book(const std::string &prefix, TTree *tree)
std::vector< float > trk_phiErr
std::vector< unsigned int > sim_nPixelLay
std::vector< float > trk_lambda
iterator end()
Return the off-the-end iterator.
Definition: DetSetVector.h:361
#define LogTrace(id)
std::vector< float > glu_zz
std::vector< float > sim_pca_lambda
std::vector< float > see_stateTrajPx
std::vector< float > glu_zx
std::shared_ptr< TrackingRecHit const > RecHitPointer
virtual RecHitPointer build(const TrackingRecHit *p) const =0
build a tracking rechit from an existing rechit
double ndof() const
Definition: Vertex.h:105
#define M_PI
Definition: RZLine.h:12
std::vector< float > vtx_xErr
static void fillDescriptions(edm::ConfigurationDescriptions &descriptions)
std::vector< std::vector< float > > trk_shareFrac
unsigned int id
bool isUpper(const DetId &id) const
std::vector< float > sim_pz
std::vector< int > event
std::vector< std::vector< int > > sim_simHitIdx
edm::Ref< TrackingVertexCollection > TrackingVertexRef
std::vector< unsigned short > isGlued
edm::EventNumber_t ev_event
void push_back(const TrackerTopology &tTopo, const DetId &id)
Definition: DetId.h:18
std::vector< unsigned short > isRPhi
std::vector< float > ph2_x
edm::EDGetTokenT< reco::VertexCollection > vertexToken_
edm::EDGetTokenT< TrackingParticleCollection > trackingParticleToken_
double x() const
x coordinate
Definition: Vertex.h:111
std::vector< int > glu_stereoIdx
std::vector< float > trk_py
double xError() const
error on x
Definition: Vertex.h:119
std::vector< std::vector< int > > pix_simHitIdx
std::vector< float > trk_nChi2
bool isFake() const
Definition: Vertex.h:72
void book(const std::string &prefix, TTree *tree)
def parse(path, config)
Definition: dumpparser.py:13
T const * product() const
Definition: Handle.h:81
std::vector< unsigned int > see_nGlued
std::vector< float > see_py
std::vector< float > pix_x
std::vector< unsigned int > detId
reco::RecoToSimCollection associateRecoToSim(const edm::Handle< edm::View< reco::Track > > &tCH, const edm::Handle< TrackingParticleCollection > &tPCH) const
compare reco to sim the handle of reco::Track and TrackingParticle collections
std::vector< int > sim_parentVtxIdx
std::vector< float > see_ptErr
std::vector< float > str_z
std::vector< unsigned short > isStack
std::vector< float > str_zx
uint32_t stack(const DetId &id) const
std::vector< TrackingVertex > TrackingVertexCollection
HistoryBase tracer_
const T & get() const
Definition: EventSetup.h:56
double sigmaZ() const
sigma z
Definition: BeamSpot.h:80
std::string algoName() const
Definition: TrackBase.h:503
bool tidIsDoubleSide(const DetId &id) const
int stripLayersWithMeasurement() const
Definition: HitPattern.h:1035
std::vector< short > trk_isHP
std::vector< float > str_xy
double BeamWidthY() const
beam width Y
Definition: BeamSpot.h:88
std::vector< std::vector< float > > str_chargeFraction
void push_back(const TrackerTopology &tTopo, const DetId &id)
void add(std::string const &label, ParameterSetDescription const &psetDescription)
std::vector< unsigned short > isLower
unsigned int tecOrder(const DetId &id) const
Base class to all the history types.
Definition: HistoryBase.h:12
int numberOfLostHits(HitCategory category) const
Definition: HitPattern.h:902
std::vector< std::vector< int > > trk_hitIdx
unsigned int layer(const DetId &id) const
void labelsForToken(EDGetToken iToken, Labels &oLabels) const
std::vector< std::vector< float > > see_shareFrac
std::vector< int > trk_q
std::vector< unsigned int > sim_nPixel
std::vector< SimHitTPPair > SimHitTPAssociationList
const bool includeAllHits_
std::vector< short > vtx_valid
bool evaluate(TrackingParticleRef tpr)
Evaluate track history using a TrackingParticleRef.
Definition: HistoryBase.h:122
edm::EventID id() const
Definition: EventBase.h:58
const EncodedEventId & eventId() const
edm::EDGetTokenT< ClusterTPAssociation > clusterTPMapToken_
unsigned int tidOrder(const DetId &id) const
Pixel cluster – collection of neighboring pixels above threshold.
fixed size matrix
std::vector< std::vector< int > > vtx_trkIdx
edm::ProductID id() const
HLT enums.
Pixel pixel(int i) const
void push_back(const TrackerTopology &tTopo, const DetId &id)
std::vector< short > str_isBarrel
auto dxy(const T_Vertex &vertex, const T_Momentum &momentum, const T_Point &point)
virtual void analyze(const edm::Event &, const edm::EventSetup &) override
void depth(int d)
Set the depth of the history.
Definition: HistoryBase.h:53
const TrackingParticleRefVector & daughterTracks() const
std::vector< float > glu_bbxi
std::vector< int > simhit_particle
std::vector< float > trk_outer_pz
edm::EDGetTokenT< edm::ValueMap< unsigned int > > tpNLayersToken_
std::vector< unsigned short > ph2_simType
std::vector< float > sim_pca_eta
void push_back(const RefToBase< T > &)
virtual OmniClusterRef const & firstClusterRef() const =0
std::vector< float > ph2_yz
std::vector< unsigned short > string
std::map< SimHitFullKey, size_t > SimHitRefKeyToIndex
static int pixelToChannel(int row, int col)
edm::EDGetTokenT< reco::BeamSpot > beamSpotToken_
std::vector< unsigned short > rod
static TrackAlgorithm algoByName(const std::string &name)
Definition: TrackBase.cc:137
double y0() const
y coordinate
Definition: BeamSpot.h:66
std::vector< float > simhit_y
void push_back(value_type const &ref)
Add a Ref<C, T> to the RefVector.
Definition: RefVector.h:69
int numberOfValidPixelHits() const
Definition: HitPattern.h:838
edm::Ref< edm::PSimHitContainer > TrackPSimHitRef
std::vector< std::vector< int > > str_simHitIdx
std::vector< float > see_statePt
std::string builderName_
size_type size() const
Size of the RefVector.
Definition: RefVector.h:107
std::vector< float > glu_xx
Monte Carlo truth information used for tracking validation.
edm::EDGetTokenT< edm::ValueMap< unsigned int > > tpNPixelLayersToken_
bool isUninitialized() const
Definition: EDGetToken.h:73
std::vector< unsigned int > trk_nPixelLay
unsigned int tecPetalNumber(const DetId &id) const
std::vector< float > simhit_x
const Point & position() const
position
Definition: BeamSpot.h:62
std::vector< float > simvtx_y
std::vector< std::vector< int > > simvtx_daughterSimIdx
std::vector< float > str_xx
#define declareDynArray(T, n, x)
Definition: DynArray.h:59
unsigned int RunNumber_t
std::vector< unsigned int > see_offset
Definition: tree.py:1
std::vector< float > ph2_zz
reco::SimToRecoCollection associateSimToReco(const edm::Handle< edm::View< reco::Track > > &tCH, const edm::Handle< TrackingParticleCollection > &tPCH) const
compare reco to sim the handle of reco::Track and TrackingParticle collections
trackRef_iterator tracks_begin() const
first iterator over tracks
Definition: Vertex.cc:76
void book(const std::string &prefix, TTree *tree)
bool isRPhi(const DetId &id) const
std::vector< int > see_trkIdx
unsigned int tobRod(const DetId &id) const
static uInt32 F(BLOWFISH_CTX *ctx, uInt32 x)
Definition: blowfish.cc:281
math::XYZVectorD Vector
point in the space
std::vector< unsigned short > side
std::vector< float > simhit_tof
Detector det() const
get the detector field from this detid
Definition: DetId.h:35
std::vector< std::vector< int > > sim_seedIdx
void fillVertices(const reco::VertexCollection &vertices, const edm::RefToBaseVector< reco::Track > &tracks)
std::vector< float > pix_xy
std::vector< unsigned short > subdet
std::vector< float > trk_dxy
RecoGenParticleTrail const & recoGenParticleTrail() const
Return all reco::GenParticle in the history.
Definition: HistoryBase.h:83
void book(const std::string &prefix, TTree *tree)
std::vector< float > sim_pt
std::vector< float > pix_yy
unsigned int key() const
std::unordered_set< reco::RecoToSimCollection::index_type > TrackingParticleRefKeySet
float chi2() const
Definition: RZLine.h:97
std::vector< unsigned int > trk_nInvalid
std::vector< decltype(reco::TrackBase().algoMaskUL())> trk_algoMask
std::vector< std::vector< int > > see_hitIdx
T const * product() const
Definition: ESHandle.h:86
Definition: vlib.h:208
std::vector< float > vtx_x
void push_back(const TrackerTopology &tTopo, const DetId &id)
std::vector< unsigned int > see_nPixel
edm::Ref< TrackingParticleCollection > TrackingParticleRef
ProductID id() const
std::vector< unsigned short > petalNumber
std::vector< float > see_eta
const std::vector< uint8_t > & amplitudes() const
unsigned int pxfPanel(const DetId &id) const
DetIdAllPhase2 simhit_detId_phase2
std::vector< unsigned int > trk_nValid
unsigned int pxfBlade(const DetId &id) const
std::vector< float > trk_inner_px
DetIdStrip glu_detId
double yError() const
error on y
Definition: Vertex.h:121
const_iterator begin(bool update=false) const
void fillSeeds(const edm::Event &iEvent, const TrackingParticleRefVector &tpCollection, const TrackingParticleRefKeyToIndex &tpKeyToIndex, const reco::BeamSpot &bs, const reco::TrackToTrackingParticleAssociator &associatorByHits, const TransientTrackingRecHitBuilder &theTTRHBuilder, const MagneticField *theMF, const std::vector< std::pair< int, int > > &monoStereoClusterList, const std::set< edm::ProductID > &hitProductIds, std::map< edm::ProductID, size_t > &seedToCollIndex)
std::vector< float > vtx_zErr
unsigned int operator[](size_t i) const
std::vector< float > simhit_eloss
Definition: event.py:1
std::vector< int > sim_isFromBHadron
edm::EDGetTokenT< edm::DetSetVector< StripDigiSimLink > > stripSimLinkToken_
std::vector< float > vtx_chi2
std::vector< int > simvtx_bunchCrossing
std::vector< float > str_bbxi
virtual TrackingParticle::Point vertex(const edm::Event &iEvent, const edm::EventSetup &iSetup, const Charge ch, const Point &vtx, const LorentzVector &lv) const
std::vector< float > see_dz
unsigned int tibOrder(const DetId &id) const
const LorentzVector & position() const
double x0() const
x coordinate
Definition: BeamSpot.h:64
std::vector< unsigned int > sim_nStrip
int size() const
Definition: vlib.h:39