CMS 3D CMS Logo

FWTrackingParticleProxyBuilderFullFramework.cc
Go to the documentation of this file.
11 
13 
17 
20 
21 #include "TEveTrack.h"
22 #include "TEveCompound.h"
23 #include "TEveManager.h"
24 #include "TEveBrowser.h"
25 #include "TEveTrackPropagator.h"
26 
28 public:
31 
32  // virtual void setItem(const FWEventItem* iItem) override;
33 
35 
36 private:
39  delete;
40 
42  void build(const FWEventItem* iItem, TEveElementList* product, const FWViewContext*) override;
43 
44  void build(const TrackingParticle& iData,
45  unsigned int iIndex,
46  TEveElement& oItemHolder,
47  const FWViewContext*) override;
48 
51 };
52 
53 //______________________________________________________________________________
54 
55 /*
56  void FWTrackingParticleProxyBuilderFullFramework::setItem(const FWEventItem* iItem)
57  {
58  printf("set item\n");
59  FWProxyBuilderBase::setItem(iItem);
60  }
61 */
62 //______________________________________________________________________________
64  TEveElementList* product,
65  const FWViewContext*) {
66  // setup event handles amd call function from parent class
67 
68  const edm::Event* event = (const edm::Event*)item()->getEvent();
69  if (event) {
70  // get collection handle
71  edm::InputTag coltag(item()->moduleLabel(), item()->productInstanceLabel(), item()->processName());
72  event->getByLabel(coltag, tpch);
73 
74  // AMT todo: check if there is any other way getting the list other than this
75  // ifnot, set proces name as a configurable parameter
77  try {
78  event->getByLabel("xxx", simHitsTPAssoc);
79  m_assocList = &*simHitsTPAssoc;
80  } catch (const std::exception& e) {
81  std::cerr << " FWTrackingParticleProxyBuilderFullFramework::setItem() Can't get hits association list "
82  << e.what() << std::endl;
83  }
84  /*
85  // debug propagator
86  gEve->GetBrowser()->MapWindow();
87  gEve->AddToListTree(context().getTrackPropagator(), true);
88  context().getTrackPropagator()->SetRnrReferences(true);
89  */
90  }
91  FWSimpleProxyBuilder::build(iItem, product, nullptr);
92 }
93 //______________________________________________________________________________
95  unsigned int tpIdx,
96  TEveElement& comp,
97  const FWViewContext*) {
98  TEveRecTrack t;
99  t.fBeta = 1.0;
100  t.fP = TEveVector(iData.px(), iData.py(), iData.pz());
101  t.fV = TEveVector(iData.vx(), iData.vy(), iData.vz());
102  t.fSign = iData.charge();
103 
104  TEveTrack* track = new TEveTrack(&t, context().getTrackPropagator());
105  if (t.fSign == 0)
106  track->SetLineStyle(7);
107 
108  track->MakeTrack();
110  // printf("add track %d \n", tpIdx);
111 
112  if (m_assocList) {
113  TEvePointSet* pointSet = new TEvePointSet;
114  setupAddElement(pointSet, &comp);
115 
116  const FWGeometry* geom = item()->getGeom();
117  float local[3];
118  float localDir[3];
119  float global[3] = {0.0, 0.0, 0.0};
120  float globalDir[3] = {0.0, 0.0, 0.0};
121 
122  TrackingParticleRef tpr(tpch, tpIdx);
123  std::pair<TrackingParticleRef, TrackPSimHitRef> clusterTPpairWithDummyTP(tpr, TrackPSimHitRef());
124  auto range = std::equal_range(m_assocList->begin(),
125  m_assocList->end(),
126  clusterTPpairWithDummyTP,
128  // printf("TrackingParticle[%d] P(%.1f, %.1f, %.1f) matches %d hits\n", tpIdx,iData.px(), iData.py(), iData.pz() ,(int)(range.second-range.first ));
129 
130  std::vector<const PSimHit*> phits;
131  for (auto ri = range.first; ri != range.second; ++ri)
132  phits.push_back(ri->second.get());
133 
134  std::sort(phits.begin(), phits.end(), [](const PSimHit* a, const PSimHit* b) { return a->tof() < b->tof(); });
135  for (auto phi = phits.begin(); phi != phits.end(); ++phi) {
136  const PSimHit* phit = *phi;
137 
138  local[0] = phit->localPosition().x();
139  local[1] = phit->localPosition().y();
140  local[2] = phit->localPosition().z();
141 
142  localDir[0] = phit->momentumAtEntry().x();
143  localDir[1] = phit->momentumAtEntry().y();
144  localDir[2] = phit->momentumAtEntry().z();
145 
146  geom->localToGlobal(phit->detUnitId(), local, global);
147  geom->localToGlobal(phit->detUnitId(), localDir, globalDir, false);
148  pointSet->SetNextPoint(global[0], global[1], global[2]);
149 
150  //printf("localP = (%f, %f, %f) globalP = (%f, %f, %f), loss = %f, tof =%f\n", localDir[0], localDir[1], localDir[2],
151  // globalDir[0], globalDir[1], globalDir[2],
152  // phit->energyLoss(), phit->tof());
153  track->AddPathMark(TEvePathMark(TEvePathMark::kReference,
154  TEveVector(global[0], global[1], global[2]),
155  TEveVector(globalDir[0], globalDir[1], globalDir[2])));
156  }
157  }
158 }
159 
162  "TrackingParticleWithPSimHits",
FastTimerService_cff.range
range
Definition: FastTimerService_cff.py:34
HLT_FULL_cff.track
track
Definition: HLT_FULL_cff.py:11713
FWGeometry
Definition: FWGeometry.h:27
FWSimpleProxyBuilderTemplate.h
ESHandle.h
PV3DBase::x
T x() const
Definition: PV3DBase.h:59
FWViewType::kAllRPZBits
static const int kAllRPZBits
Definition: FWViewType.h:67
REGISTER_FWPROXYBUILDER
#define REGISTER_FWPROXYBUILDER(_name_, _type_, _purpose_, _view_)
Definition: FWProxyBuilderFactory.h:33
phits
const caConstants::TupleMultiplicity *__restrict__ const HitsOnGPU *__restrict__ double *__restrict__ phits
Definition: BrokenLineFitOnGPU.h:27
PSimHitContainer.h
FWProxyBuilderBase.h
TrackingParticle::vy
double vy() const
y coordinate of parent vertex position
Definition: TrackingParticle.h:172
TrackingParticle::py
double py() const
y coordinate of momentum vector. Note this is taken from the first SimTrack only.
Definition: TrackingParticle.h:136
REGISTER_PROXYBUILDER_METHODS
#define REGISTER_PROXYBUILDER_METHODS()
Definition: register_dataproxybuilder_macro.h:28
FWParameters.h
EventBase.h
edm::Handle< TrackingParticleCollection >
AlCaHLTBitMon_QueryRunRegistry.comp
comp
Definition: AlCaHLTBitMon_QueryRunRegistry.py:249
edm::Ref< TrackingParticleCollection >
PSimHit::detUnitId
unsigned int detUnitId() const
Definition: PSimHit.h:97
FWViewType::kAll3DBits
static const int kAll3DBits
Definition: FWViewType.h:68
PV3DBase::z
T z() const
Definition: PV3DBase.h:61
TrackingParticle::charge
float charge() const
Electric charge. Note this is taken from the first SimTrack only.
Definition: TrackingParticle.h:98
TrackingParticle::px
double px() const
x coordinate of momentum vector. Note this is taken from the first SimTrack only.
Definition: TrackingParticle.h:133
TrackingRecHit.h
TrackingParticle
Monte Carlo truth information used for tracking validation.
Definition: TrackingParticle.h:29
PSimHit::localPosition
Local3DPoint localPosition() const
Definition: PSimHit.h:52
relativeConstraints.geom
geom
Definition: relativeConstraints.py:72
b
double b
Definition: hdecay.h:118
FWTrackingParticleProxyBuilderFullFramework::m_assocList
const SimHitTPAssociationProducer::SimHitTPAssociationList * m_assocList
Definition: FWTrackingParticleProxyBuilderFullFramework.cc:50
FWEventItem::getEvent
const edm::EventBase * getEvent() const
Definition: FWEventItem.h:131
cppFunctionSkipper.exception
exception
Definition: cppFunctionSkipper.py:10
FWGeometry.h
FWTrackingParticleProxyBuilderFullFramework
Definition: FWTrackingParticleProxyBuilderFullFramework.cc:27
a
double a
Definition: hdecay.h:119
TrackingParticle::vz
double vz() const
Definition: TrackingParticle.h:177
jetUpdater_cfi.sort
sort
Definition: jetUpdater_cfi.py:29
FWProxyBuilderConfiguration.h
PV3DBase::y
T y() const
Definition: PV3DBase.h:60
FWProxyBuilderBase::setupAddElement
void setupAddElement(TEveElement *el, TEveElement *parent, bool set_color=true) const
Definition: FWProxyBuilderBase.cc:350
FWTrackingParticleProxyBuilderFullFramework::~FWTrackingParticleProxyBuilderFullFramework
~FWTrackingParticleProxyBuilderFullFramework(void) override
Definition: FWTrackingParticleProxyBuilderFullFramework.cc:30
TrackingParticle::pz
double pz() const
z coordinate of momentum vector. Note this is taken from the first SimTrack only.
Definition: TrackingParticle.h:139
FWProxyBuilderBase::build
void build()
Definition: FWProxyBuilderBase.cc:110
FWEventItem.h
FWViewContext
Definition: FWViewContext.h:32
SimL1EmulatorRepack_CalouGT_cff.processName
processName
Definition: SimL1EmulatorRepack_CalouGT_cff.py:17
SimHitTPAssociationProducer.h
FWEventItem::getGeom
const FWGeometry * getGeom() const
Definition: FWEventItem.cc:548
DDAxes::phi
FWProxyBuilderBase::item
const FWEventItem * item() const
Definition: FWProxyBuilderBase.h:64
SimHitTPAssociationProducer::SimHitTPAssociationList
std::vector< SimHitTPPair > SimHitTPAssociationList
Definition: SimHitTPAssociationProducer.h:18
TrackingParticle.h
TrackingParticle::vx
double vx() const
x coordinate of parent vertex position
Definition: TrackingParticle.h:166
FWEventItem
Definition: FWEventItem.h:56
DetId.h
TrackingParticleFwd.h
PSimHit::momentumAtEntry
LocalVector momentumAtEntry() const
The momentum of the track that produced the hit, at entry point.
Definition: PSimHit.h:55
TrackPSimHitRef
edm::Ref< edm::PSimHitContainer > TrackPSimHitRef
Definition: PSimHitContainer.h:14
FWTrackingParticleProxyBuilderFullFramework::tpch
edm::Handle< TrackingParticleCollection > tpch
Definition: FWTrackingParticleProxyBuilderFullFramework.cc:49
FWProxyBuilderBase::context
const fireworks::Context & context() const
Definition: FWProxyBuilderBase.cc:412
FWTrackingParticleProxyBuilderFullFramework::FWTrackingParticleProxyBuilderFullFramework
FWTrackingParticleProxyBuilderFullFramework(void)
Definition: FWTrackingParticleProxyBuilderFullFramework.cc:29
FWTrackingParticleProxyBuilderFullFramework::operator=
const FWTrackingParticleProxyBuilderFullFramework & operator=(const FWTrackingParticleProxyBuilderFullFramework &)=delete
FWSimpleProxyBuilderTemplate
Definition: FWSimpleProxyBuilderTemplate.h:30
DTRecHitClients_cfi.local
local
Definition: DTRecHitClients_cfi.py:10
HerwigMaxPtPartonFilter_cfi.moduleLabel
moduleLabel
Definition: HerwigMaxPtPartonFilter_cfi.py:4
PSimHit
Definition: PSimHit.h:15
event
Definition: event.py:1
edm::Event
Definition: Event.h:73
submitPVValidationJobs.t
string t
Definition: submitPVValidationJobs.py:644
EcnaPython_AdcPeg12_S1_10_R170298_1_0_150_Dee0.cerr
cerr
Definition: EcnaPython_AdcPeg12_S1_10_R170298_1_0_150_Dee0.py:8
edm::InputTag
Definition: InputTag.h:15
Context.h
MillePedeFileConverter_cfg.e
e
Definition: MillePedeFileConverter_cfg.py:37
SimHitTPAssociationProducer::simHitTPAssociationListGreater
static bool simHitTPAssociationListGreater(SimHitTPPair i, SimHitTPPair j)
Definition: SimHitTPAssociationProducer.h:23