CMS 3D CMS Logo

InputData.cc
Go to the documentation of this file.
14 
20 
21 #include <map>
22 #include <memory>
23 
24 using namespace std;
25 
26 namespace tmtt {
27 
28  InputData::InputData(const edm::Event& iEvent,
29  const edm::EventSetup& iSetup,
30  const Settings* settings,
31  StubWindowSuggest* stubWindowSuggest,
32  const DegradeBend* degradeBend,
33  const TrackerGeometry* trackerGeometry,
34  const TrackerTopology* trackerTopology,
35  const list<TrackerModule>& listTrackerModule,
37  const edm::EDGetTokenT<TTStubDetSetVec> stubToken,
38  const edm::EDGetTokenT<TTStubAssMap> stubTruthToken,
39  const edm::EDGetTokenT<TTClusterAssMap> clusterTruthToken,
41  : // Note if job will use MC truth info (or skip it to save CPU).
42  enableMCtruth_(settings->enableMCtruth()) {
44  edm::Handle<TTStubDetSetVec> ttStubHandle;
45  edm::Handle<TTStubAssMap> mcTruthTTStubHandle;
46  edm::Handle<TTClusterAssMap> mcTruthTTClusterHandle;
48  iEvent.getByToken(stubToken, ttStubHandle);
49  if (enableMCtruth_) {
50  iEvent.getByToken(tpToken, tpHandle);
51  iEvent.getByToken(stubTruthToken, mcTruthTTStubHandle);
52  iEvent.getByToken(clusterTruthToken, mcTruthTTClusterHandle);
53  iEvent.getByToken(genJetToken, genJetHandle);
54  }
55 
56  // Get TrackingParticle info
57 
58  if (enableMCtruth_) {
59  unsigned int tpCount = 0;
60  for (unsigned int i = 0; i < tpHandle->size(); i++) {
61  const TrackingParticle& tPart = tpHandle->at(i);
62  // Creating Ptr uses CPU, so apply Pt cut here, copied from TP::fillUse(), to avoid doing it too often.
63  constexpr float ptMinScale = 0.7;
64  const float ptMin = min(settings->genMinPt(), ptMinScale * settings->houghMinPt());
65  if (tPart.pt() > ptMin) {
66  TrackingParticlePtr tpPtr(tpHandle, i);
67  // Store the TrackingParticle info, using class TP to provide easy access to the most useful info.
68  TP tp(tpPtr, tpCount, settings);
69  // Only bother storing tp if it could be useful for tracking efficiency or fake rate measurements.
70  if (tp.use()) {
71  if (genJetHandle.isValid()) {
72  tp.fillNearestJetInfo(genJetHandle.product());
73  }
74 
75  vTPs_.push_back(tp);
76  tpCount++;
77  }
78  }
79  }
80  }
81 
82  // Also create map relating edm::Ptr<TrackingParticle> to TP.
83 
84  map<edm::Ptr<TrackingParticle>, const TP*> translateTP;
85 
86  if (enableMCtruth_) {
87  for (const TP& tp : vTPs_) {
88  const TrackingParticlePtr& tpPtr = tp.trackingParticlePtr();
89  translateTP[tpPtr] = &tp;
90  }
91  }
92 
93  // Initialize code for killing some stubs to model detector problems.
94  const StubKiller::KillOptions killOpt = static_cast<StubKiller::KillOptions>(settings->killScenario());
95  std::unique_ptr<const StubKiller> stubKiller;
96  if (killOpt != StubKiller::KillOptions::none) {
97  stubKiller = std::make_unique<StubKiller>(killOpt, trackerTopology, trackerGeometry, iEvent);
98  }
99 
100  // Loop over tracker modules to get module info & stubs.
101 
102  for (const TrackerModule& trackerModule : listTrackerModule) {
103  const DetId& stackedDetId = trackerModule.stackedDetId();
104  TTStubDetSetVec::const_iterator p_module = ttStubHandle->find(stackedDetId);
105  if (p_module != ttStubHandle->end()) {
106  for (TTStubDetSet::const_iterator p_ttstub = p_module->begin(); p_ttstub != p_module->end(); p_ttstub++) {
107  TTStubRef ttStubRef = edmNew::makeRefTo(ttStubHandle, p_ttstub);
108  const unsigned int stubIndex = vAllStubs_.size();
109 
110  // Store the Stub info, using class Stub to provide easy access to the most useful info.
111  vAllStubs_.emplace_back(
112  ttStubRef, stubIndex, settings, trackerTopology, &trackerModule, degradeBend, stubKiller.get());
113 
114  // Also fill truth associating stubs to tracking particles.
115  if (enableMCtruth_) {
116  Stub& stub = vAllStubs_.back();
117  stub.fillTruth(translateTP, mcTruthTTStubHandle, mcTruthTTClusterHandle);
118  }
119  }
120  }
121  }
122 
123  // Produced reduced list containing only the subset of stubs that the user has declared will be
124  // output by the front-end readout electronics.
125  for (Stub& s : vAllStubs_) {
126  if (s.frontendPass()) {
127  vStubs_.push_back(&s);
128  vStubsConst_.push_back(&s);
129  }
130  }
131  // Optionally sort stubs according to bend, so highest Pt ones are sent from DTC to GP first.
132  if (settings->orderStubsByBend()) {
133  auto orderStubsByBend = [](const Stub* a, const Stub* b) { return (std::abs(a->bend()) < std::abs(b->bend())); };
134  vStubs_.sort(orderStubsByBend);
135  }
136 
137  // Note list of stubs produced by each tracking particle.
138  // (By passing vAllStubs_ here instead of vStubs_, it means that any algorithmic efficiencies
139  // measured will be reduced if the tightened frontend electronics cuts, specified in section StubCuts
140  // of Analyze_Defaults_cfi.py, are not 100% efficient).
141  if (enableMCtruth_) {
142  for (TP& tp : vTPs_) {
143  tp.fillTruth(vAllStubs_);
144  }
145  }
146 
147  // If requested, recommend better FE stub window cuts.
148  if (settings->printStubWindows()) {
149  for (const Stub& s : vAllStubs_) {
150  stubWindowSuggest->process(trackerTopology, &s);
151  }
152  }
153  }
154 
155 } // namespace tmtt
tmtt::Settings::houghMinPt
double houghMinPt() const
Definition: Settings.h:135
GenJetCollection.h
tmtt::InputData::vTPs_
std::list< TP > vTPs_
Definition: InputData.h:57
mps_fire.i
i
Definition: mps_fire.py:355
TrackerGeometry.h
edm::Handle::product
T const * product() const
Definition: Handle.h:70
ESHandle.h
min
T min(T a, T b)
Definition: MathUtil.h:58
edm::EDGetTokenT< TrackingParticleCollection >
TrackerTopology
Definition: TrackerTopology.h:16
tmtt::StubWindowSuggest::process
void process(const TrackerTopology *trackerTopo, const Stub *stub)
Definition: StubWindowSuggest.cc:30
edmNew::makeRefTo
edm::Ref< typename HandleT::element_type, typename HandleT::element_type::value_type::value_type > makeRefTo(const HandleT &iHandle, typename HandleT::element_type::value_type::const_iterator itIter)
Definition: DetSetVectorNew.h:735
ptMin
constexpr float ptMin
Definition: PhotonIDValueMapProducer.cc:153
edmNew::DetSetVector::const_iterator
boost::transform_iterator< IterHelp, const_IdIter > const_iterator
Definition: DetSetVectorNew.h:231
tmtt::TrackerModule
Definition: TrackerModule.h:23
EDAnalyzer.h
tmtt::TP
Definition: TP.h:23
edm::Handle< TrackingParticleCollection >
tmtt::StubWindowSuggest
Definition: StubWindowSuggest.h:28
StubKiller.h
edm::Ref< TTStubDetSetVec, TTStub< Ref_Phase2TrackerDigi_ > >
tmtt::InputData::vStubsConst_
std::list< const Stub * > vStubsConst_
Definition: InputData.h:59
DetId
Definition: DetId.h:17
TrackerTopology.h
alignCSCRings.s
s
Definition: alignCSCRings.py:92
edmNew::DetSetVector::find
const_iterator find(id_type i, bool update=false) const
Definition: DetSetVectorNew.h:560
TrackingParticle::pt
double pt() const
Transverse momentum. Note this is taken from the first SimTrack only.
Definition: TrackingParticle.h:142
TrackingParticle
Monte Carlo truth information used for tracking validation.
Definition: TrackingParticle.h:29
tmtt::Stub::fillTruth
void fillTruth(const std::map< edm::Ptr< TrackingParticle >, const TP * > &translateTP, const edm::Handle< TTStubAssMap > &mcTruthTTStubHandle, const edm::Handle< TTClusterAssMap > &mcTruthTTClusterHandle)
Definition: Stub.cc:328
b
double b
Definition: hdecay.h:118
cmsswSequenceInfo.tp
tp
Definition: cmsswSequenceInfo.py:17
StubWindowSuggest.h
TrackerDigiGeometryRecord.h
tmtt::Settings::printStubWindows
bool printStubWindows() const
Definition: Settings.h:68
a
double a
Definition: hdecay.h:119
Event.h
tmtt::StubKiller::KillOptions
KillOptions
Definition: StubKiller.h:22
tmtt::StubKiller::KillOptions::none
tmtt::Settings
Definition: Settings.h:17
iEvent
int iEvent
Definition: GenABIO.cc:224
edm::EventSetup
Definition: EventSetup.h:57
tmtt::InputData::enableMCtruth_
bool enableMCtruth_
Definition: InputData.h:53
genTree_cfi.genJetToken
genJetToken
Definition: genTree_cfi.py:5
tmtt::Settings::orderStubsByBend
bool orderStubsByBend() const
Definition: Settings.h:76
InputTag.h
edm::Ptr< TrackingParticle >
TrackingParticle.h
tmtt::InputData::vStubs_
std::list< Stub * > vStubs_
Definition: InputData.h:58
std
Definition: JetResolutionObject.h:76
tmtt::DegradeBend
Definition: DegradeBend.h:15
Settings.h
edmNew::DetSetVector::end
const_iterator end(bool update=false) const
Definition: DetSetVectorNew.h:577
EventSetup.h
GenJet.h
funct::abs
Abs< T >::type abs(const T &t)
Definition: Abs.h:22
SimTrack.h
DegradeBend.h
edm::HandleBase::isValid
bool isValid() const
Definition: HandleBase.h:70
tmtt::Stub
Definition: Stub.h:43
edm::Event
Definition: Event.h:73
tmtt
=== This is the base class for the linearised chi-squared track fit algorithms.
Definition: ChiSquaredFit4.h:6
tmtt::InputData::vAllStubs_
std::list< Stub > vAllStubs_
Definition: InputData.h:64
InputData.h
tmtt::Settings::killScenario
unsigned int killScenario() const
Definition: Settings.h:341
tmtt::Settings::genMinPt
double genMinPt() const
Definition: Settings.h:48
TrackerGeometry
Definition: TrackerGeometry.h:14
edmNew::DetSet::const_iterator
const data_type * const_iterator
Definition: DetSetNew.h:31
EncodedEventId.h