CMS 3D CMS Logo

List of all members | Public Member Functions | Private Types | Private Attributes
SiPixelPhase1TrackingParticleV Class Reference

#include <SiPixelPhase1TrackingParticleV.h>

Inheritance diagram for SiPixelPhase1TrackingParticleV:
SiPixelPhase1Base one::DQMEDAnalyzer< T > HistogramManagerHolder one::dqmimplementation::DQMBaseClass< T... >

Public Member Functions

void analyze (const edm::Event &, const edm::EventSetup &) override
 
 SiPixelPhase1TrackingParticleV (const edm::ParameterSet &conf)
 
- Public Member Functions inherited from SiPixelPhase1Base
void analyze (edm::Event const &e, edm::EventSetup const &eSetup) override=0
 
void bookHistograms (DQMStore::IBooker &iBooker, edm::Run const &run, edm::EventSetup const &iSetup) override
 
 SiPixelPhase1Base (const edm::ParameterSet &iConfig)
 
 ~SiPixelPhase1Base () override
 
- Public Member Functions inherited from one::DQMEDAnalyzer< T >
 DQMEDAnalyzer ()=default
 
 DQMEDAnalyzer (DQMEDAnalyzer< T... > const &)=delete
 
 DQMEDAnalyzer (DQMEDAnalyzer< T... > &&)=delete
 
 ~DQMEDAnalyzer () override=default
 
- Public Member Functions inherited from HistogramManagerHolder
 HistogramManagerHolder (const edm::ParameterSet &iConfig)
 

Private Types

enum  {
  MASS, CHARGE, ID, NHITS,
  MATCHED, PT, PHI, ETA,
  VTX, VTY, VYZ, TIP,
  LIP
}
 

Private Attributes

std::vector< edm::EDGetTokenT< std::vector< PSimHit > > > simHitTokens_
 
edm::EDGetTokenT< TrackingParticleCollectionvec_TrackingParticle_Token_
 

Additional Inherited Members

- Protected Types inherited from SiPixelPhase1Base
enum  { DCS }
 
- Protected Member Functions inherited from SiPixelPhase1Base
bool checktrigger (const edm::Event &iEvent, const edm::EventSetup &iSetup, const unsigned trgidx) const
 
- Protected Attributes inherited from HistogramManagerHolder
GeometryInterface geometryInterface
 
std::vector< HistogramManagerhisto
 

Detailed Description

Definition at line 21 of file SiPixelPhase1TrackingParticleV.h.

Member Enumeration Documentation

anonymous enum
private

Constructor & Destructor Documentation

SiPixelPhase1TrackingParticleV::SiPixelPhase1TrackingParticleV ( const edm::ParameterSet conf)
explicit

Definition at line 45 of file SiPixelPhase1TrackingParticleV.cc.

References edm::ParameterSet::getParameter(), simHitTokens_, and GlobalPosition_Frontier_DevDB_cff::tag.

46  : SiPixelPhase1Base(iConfig),
47  vec_TrackingParticle_Token_(consumes<TrackingParticleCollection>(iConfig.getParameter<edm::InputTag>("src"))) {
48  for (const auto &tag : iConfig.getParameter<std::vector<edm::InputTag>>("simHitToken")) {
49  simHitTokens_.push_back(consumes<std::vector<PSimHit>>(tag));
50  }
51 }
SiPixelPhase1Base(const edm::ParameterSet &iConfig)
edm::EDGetTokenT< TrackingParticleCollection > vec_TrackingParticle_Token_
std::vector< edm::EDGetTokenT< std::vector< PSimHit > > > simHitTokens_

Member Function Documentation

void SiPixelPhase1TrackingParticleV::analyze ( const edm::Event iEvent,
const edm::EventSetup iSetup 
)
override

Definition at line 53 of file SiPixelPhase1TrackingParticleV.cc.

References CHARGE, DEFINE_FWK_MODULE, PSimHit::detUnitId(), ETA, PSimHit::eventId(), edm::Event::getByToken(), HistogramManagerHolder::histo, ID, triggerObjects_cff::id, iEvent, LIP, MASS, MATCHED, NHITS, PHI, PixelSubdetector::PixelBarrel, PixelSubdetector::PixelEndcap, edm::Handle< T >::product(), PT, rpcPointValidation_cfi::simHit, SiPixelPhase1TrackingParticleV_cfi::simHitToken, simHitTokens_, muonSimHitMatcherPSet::simTrack, mathSSE::sqrt(), protons_cff::t, TIP, vec_TrackingParticle_Token_, VTX, VTY, and VYZ.

53  {
54  edm::Handle<TrackingParticleCollection> TruthTrackContainer;
55  iEvent.getByToken(vec_TrackingParticle_Token_, TruthTrackContainer);
56  const TrackingParticleCollection *tPC = TruthTrackContainer.product();
57  std::vector<std::pair<unsigned int, const PSimHit *>> trackIdToHitPtr;
58 
59  // A multimap linking SimTrack::trackId() to a pointer to PSimHit
60  // Similar to TrackingTruthAccumulator
61  for (const auto &simHitToken : simHitTokens_) {
63  iEvent.getByToken(simHitToken, hsimhits);
64  trackIdToHitPtr.reserve(trackIdToHitPtr.size() + hsimhits->size());
65  for (const auto &simHit : *hsimhits) {
66  trackIdToHitPtr.emplace_back(simHit.trackId(), &simHit);
67  }
68  }
69  std::stable_sort(trackIdToHitPtr.begin(), trackIdToHitPtr.end(), trackIdHitPairLessSort);
70 
71  // Loop over TrackingParticle's
72  for (TrackingParticleCollection::const_iterator t = tPC->begin(); t != tPC->end(); ++t) {
73  // histo manager requires a det ID, use first tracker hit
74 
75  bool isBpixtrack = false, isFpixtrack = false;
76  DetId id;
77 
78  for (const SimTrack &simTrack : t->g4Tracks()) {
79  // Logic is from TrackingTruthAccumulator
80  auto range = std::equal_range(trackIdToHitPtr.begin(),
81  trackIdToHitPtr.end(),
82  std::pair<unsigned int, const PSimHit *>(simTrack.trackId(), nullptr),
83  trackIdHitPairLess);
84  if (range.first == range.second)
85  continue;
86 
87  auto iHitPtr = range.first;
88  for (; iHitPtr != range.second; ++iHitPtr) {
89  const PSimHit &simHit = *(iHitPtr->second);
90  if (simHit.eventId() != t->eventId())
91  continue;
92  id = DetId(simHit.detUnitId());
93 
94  // check we are in pixel
95  uint32_t subdetid = (id.subdetId());
96  if (subdetid == PixelSubdetector::PixelBarrel)
97  isBpixtrack = true;
98  if (subdetid == PixelSubdetector::PixelEndcap)
99  isFpixtrack = true;
100  if (subdetid != PixelSubdetector::PixelBarrel && subdetid != PixelSubdetector::PixelEndcap)
101  continue;
102  }
103  }
104 
105  if (isBpixtrack || isFpixtrack) {
106  histo[MASS].fill(t->mass(), id, &iEvent);
107  histo[CHARGE].fill(t->charge(), id, &iEvent);
108  histo[ID].fill(t->pdgId(), id, &iEvent);
109  histo[NHITS].fill(t->numberOfTrackerHits(), id, &iEvent);
110  histo[MATCHED].fill(t->numberOfTrackerLayers(), id, &iEvent);
111  histo[PT].fill(sqrt(t->momentum().perp2()), id, &iEvent);
112  histo[PHI].fill(t->momentum().Phi(), id, &iEvent);
113  histo[ETA].fill(t->momentum().eta(), id, &iEvent);
114  histo[VTX].fill(t->vx(), id, &iEvent);
115  histo[VTY].fill(t->vy(), id, &iEvent);
116  histo[VYZ].fill(t->vz(), id, &iEvent);
117  histo[TIP].fill(sqrt(t->vertex().perp2()), id, &iEvent);
118  histo[LIP].fill(t->vz(), id, &iEvent);
119  }
120  }
121 }
std::vector< TrackingParticle > TrackingParticleCollection
bool getByToken(EDGetToken token, Handle< PROD > &result) const
Definition: Event.h:517
int iEvent
Definition: GenABIO.cc:224
T sqrt(T t)
Definition: SSEVec.h:18
EncodedEventId eventId() const
Definition: PSimHit.h:108
edm::EDGetTokenT< TrackingParticleCollection > vec_TrackingParticle_Token_
Definition: DetId.h:18
T const * product() const
Definition: Handle.h:74
std::vector< HistogramManager > histo
std::vector< edm::EDGetTokenT< std::vector< PSimHit > > > simHitTokens_
unsigned int detUnitId() const
Definition: PSimHit.h:97

Member Data Documentation

std::vector<edm::EDGetTokenT<std::vector<PSimHit> > > SiPixelPhase1TrackingParticleV::simHitTokens_
private

Definition at line 44 of file SiPixelPhase1TrackingParticleV.h.

Referenced by analyze(), and SiPixelPhase1TrackingParticleV().

edm::EDGetTokenT<TrackingParticleCollection> SiPixelPhase1TrackingParticleV::vec_TrackingParticle_Token_
private

Definition at line 43 of file SiPixelPhase1TrackingParticleV.h.

Referenced by analyze().