CMS 3D CMS Logo

TrajectorySeedProducer.cc
Go to the documentation of this file.
1 
21 // system
22 #include <memory>
23 #include <vector>
24 #include <string>
25 
26 // framework
34 
35 // data formats
40 
41 // reco track classes
46 
47 // geometry
49 
50 // fastsim
56 
57 class MeasurementTracker;
58 
60 private:
61  // tokens
62 
66 
67  // other data members
68  unsigned int nHitsPerSeed_;
69 
70  std::vector<std::vector<TrackingLayer>> seedingLayers;
72 
73  std::unique_ptr<SeedCreator> seedCreator;
75 
76  std::unique_ptr<SeedFinderSelector> seedFinderSelector;
77 
78 public:
80 
81  void produce(edm::Event& e, const edm::EventSetup& es) override;
82 };
83 
84 template class SeedingTree<TrackingLayer>;
85 template class SeedingNode<TrackingLayer>;
86 
88  // products
89  produces<TrajectorySeedCollection>();
90 
91  // consumes
93  consumes<FastTrackerRecHitCombinationCollection>(conf.getParameter<edm::InputTag>("recHitCombinations"));
94  if (conf.exists("hitMasks")) {
95  hitMasksToken = consumes<std::vector<bool>>(conf.getParameter<edm::InputTag>("hitMasks"));
96  }
97 
98  // read Layers
99  std::vector<std::string> layerStringList =
100  conf.getParameter<edm::ParameterSet>("seedFinderSelector").getParameter<std::vector<std::string>>("layerList");
101  std::string layerBegin = *(layerStringList.cbegin());
102  nHitsPerSeed_ = 0;
103  for (auto it = layerStringList.cbegin(); it < layerStringList.cend(); ++it) {
104  std::vector<TrackingLayer> trackingLayerList;
105  std::string line = *it;
107  unsigned int nHitsPerSeed = 0;
108  while (pos != std::string::npos) {
109  pos = line.find('+');
110  std::string layer = line.substr(0, pos);
112  trackingLayerList.push_back(layerSpec);
113  line = line.substr(pos + 1, std::string::npos);
114  nHitsPerSeed++;
115  }
116  if (it == layerStringList.cbegin()) {
117  nHitsPerSeed_ = nHitsPerSeed;
118  } else if (nHitsPerSeed_ != nHitsPerSeed) {
119  throw cms::Exception("FastSimTracking") << "All allowed seed layer definitions must have same elements";
120  }
121  _seedingTree.insert(trackingLayerList);
122  }
123 
124  // seed finder selector
125  if (conf.exists("seedFinderSelector")) {
126  seedFinderSelector = std::make_unique<SeedFinderSelector>(
127  conf.getParameter<edm::ParameterSet>("seedFinderSelector"), consumesCollector());
128  }
129 
131  trackingRegionToken = consumes<edm::OwnVector<TrackingRegion>>(conf.getParameter<edm::InputTag>("trackingRegions"));
132 
133  // seed creator
134  const edm::ParameterSet& seedCreatorPSet = conf.getParameter<edm::ParameterSet>("SeedCreatorPSet");
135  std::string seedCreatorName = seedCreatorPSet.getParameter<std::string>("ComponentName");
136  seedCreator = SeedCreatorFactory::get()->create(seedCreatorName, seedCreatorPSet);
137 }
138 
140  // services
141  edm::ESHandle<TrackerTopology> trackerTopology;
142 
143  es.get<TrackerTopologyRcd>().get(trackerTopology);
144 
145  // input data
148  const std::vector<bool>* hitMasks = nullptr;
150  edm::Handle<std::vector<bool>> hitMasksHandle;
151  e.getByToken(hitMasksToken, hitMasksHandle);
152  hitMasks = &(*hitMasksHandle);
153  }
154 
155  // output data
156  std::unique_ptr<TrajectorySeedCollection> output(new TrajectorySeedCollection());
157 
158  // read the regions;
160  e.getByToken(trackingRegionToken, hregions);
161  const auto& regions = *hregions;
162  // and make sure there is at least one region
163  if (regions.empty()) {
164  e.put(std::move(output));
165  return;
166  }
167 
168  // instantiate the seed finder
169  SeedFinder seedFinder(_seedingTree, *trackerTopology.product());
170  if (seedFinderSelector) {
171  seedFinderSelector->initEvent(e, es);
172  seedFinder.addHitSelector(seedFinderSelector.get(), nHitsPerSeed_);
173  }
174 
175  // loop over the combinations
176  for (unsigned icomb = 0; icomb < recHitCombinations->size(); ++icomb) {
177  FastTrackerRecHitCombination recHitCombination = (*recHitCombinations)[icomb];
178 
179  // create a list of hits cleaned from masked hits
180  std::vector<const FastTrackerRecHit*> seedHitCandidates;
181  for (const auto& _hit : recHitCombination) {
183  continue;
184  }
185  seedHitCandidates.push_back(_hit.get());
186  }
187 
188  // loop over the regions
189  for (const auto& region : regions) {
190  // set the region used in the selector
191  if (seedFinderSelector) {
192  seedFinderSelector->setTrackingRegion(&region);
193  }
194 
195  // find hits compatible with the seed requirements
196  std::vector<unsigned int> seedHitNumbers = seedFinder.getSeed(seedHitCandidates);
197 
198  // create a seed from those hits
199  if (seedHitNumbers.size() > 1) {
200  // copy the hits
202  for (unsigned iIndex = 0; iIndex < seedHitNumbers.size(); ++iIndex) {
203  seedHits.push_back(seedHitCandidates[seedHitNumbers[iIndex]]->clone());
204  }
205  // make them aware of the combination they originate from
207 
208  // create the seed
209  seedCreator->init(region, es, nullptr);
210  seedCreator->makeSeed(*output,
211  SeedingHitSet(&seedHits[0],
212  &seedHits[1],
213  seedHits.size() >= 3 ? &seedHits[2] : nullptr,
214  seedHits.size() >= 4 ? &seedHits[3] : nullptr));
215  break; // break the loop over the regions
216  }
217  }
218  }
219  e.put(std::move(output));
220 }
221 
edm::ESHandle::product
T const * product() const
Definition: ESHandle.h:86
SeedCreatorFactory.h
SeedFinder
Definition: SeedFinder.h:17
Handle.h
SeedFinderSelector.h
DetachedQuadStep_cff.hitMasks
hitMasks
Definition: DetachedQuadStep_cff.py:100
TrajectorySeedCollection
std::vector< TrajectorySeed > TrajectorySeedCollection
Definition: TrajectorySeedCollection.h:6
TrajectorySeedProducer::seedingLayers
std::vector< std::vector< TrackingLayer > > seedingLayers
Definition: TrajectorySeedProducer.cc:70
ESHandle.h
FastTrackingUtilities.h
SeedingHitSet
Definition: SeedingHitSet.h:6
convertSQLitetoXML_cfg.output
output
Definition: convertSQLitetoXML_cfg.py:72
edm::EDGetTokenT< FastTrackerRecHitCombinationCollection >
pos
Definition: PixelAliasList.h:18
fastTrackingUtilities::setRecHitCombinationIndex
void setRecHitCombinationIndex(edm::OwnVector< T > &recHits, int32_t icomb)
Definition: FastTrackingUtilities.h:11
fastTrackingUtilities::hitIsMasked
bool hitIsMasked(const FastTrackerRecHit *hit, const std::vector< bool > &hitMasks)
Definition: FastTrackingUtilities.h:39
TrajectorySeedProducer::seedFinderSelector
std::unique_ptr< SeedFinderSelector > seedFinderSelector
Definition: TrajectorySeedProducer.cc:76
edm::EDGetTokenT::isUninitialized
constexpr bool isUninitialized() const noexcept
Definition: EDGetToken.h:99
EDProducer.h
edm::Handle< FastTrackerRecHitCombinationCollection >
TrajectorySeedProducer::seedCreator
std::unique_ptr< SeedCreator > seedCreator
Definition: TrajectorySeedProducer.cc:73
MeasurementTracker
Definition: MeasurementTracker.h:21
SeedFinder.h
MakerMacros.h
SeedingTree.h
trigger::size_type
uint16_t size_type
Definition: TriggerTypeDefs.h:18
TrackerTopologyRcd.h
edm::EventSetup::get
T get() const
Definition: EventSetup.h:87
DEFINE_FWK_MODULE
#define DEFINE_FWK_MODULE(type)
Definition: MakerMacros.h:16
clone
TEveGeoShape * clone(const TEveElement *element, TEveElement *parent)
Definition: eve_macros.cc:135
SeedingHitSet.h
SeedingTree::insert
bool insert(const std::vector< DATA > &dataList)
Definition: SeedingTree.h:126
edm::ESHandle< TrackerTopology >
phase1PixelTopology::layer
constexpr std::array< uint8_t, layerIndexSize > layer
Definition: phase1PixelTopology.h:99
TrackingLayer.h
TrajectorySeedProducer
Definition: TrajectorySeedProducer.cc:59
edm::ParameterSet::exists
bool exists(std::string const &parameterName) const
checks if a parameter exists
Definition: ParameterSet.cc:681
edm::ParameterSet
Definition: ParameterSet.h:47
TrajectorySeedProducer::_seedingTree
SeedingTree< TrackingLayer > _seedingTree
Definition: TrajectorySeedProducer.cc:71
Event.h
TrajectorySeedProducer::trackingRegionToken
edm::EDGetTokenT< edm::OwnVector< TrackingRegion > > trackingRegionToken
Definition: TrajectorySeedProducer.cc:65
TrajectorySeedProducer::measurementTrackerLabel
std::string measurementTrackerLabel
Definition: TrajectorySeedProducer.cc:74
HLT_FULL_cff.region
region
Definition: HLT_FULL_cff.py:88286
TrajectorySeedProducer::nHitsPerSeed_
unsigned int nHitsPerSeed_
Definition: TrajectorySeedProducer.cc:68
edm::stream::EDProducer
Definition: EDProducer.h:36
edm::EventSetup
Definition: EventSetup.h:58
FastTrackerRecHitCollection.h
get
#define get
TrajectorySeedCollection.h
AlCaHLTBitMon_QueryRunRegistry.string
string string
Definition: AlCaHLTBitMon_QueryRunRegistry.py:256
InputTag.h
HLT_FULL_cff.seedFinder
seedFinder
Definition: HLT_FULL_cff.py:13232
SeedingTree< TrackingLayer >
TrajectorySeedProducer::recHitCombinationsToken
edm::EDGetTokenT< FastTrackerRecHitCombinationCollection > recHitCombinationsToken
Definition: TrajectorySeedProducer.cc:63
TrackCandidateProducer_cfi.recHitCombinations
recHitCombinations
Definition: TrackCandidateProducer_cfi.py:5
eostools.move
def move(src, dest)
Definition: eostools.py:511
TrajectorySeedProducer::produce
void produce(edm::Event &e, const edm::EventSetup &es) override
Definition: TrajectorySeedProducer.cc:139
TrackingLayer
Definition: TrackingLayer.h:9
FastTrackerRecHitCombination
std::vector< FastTrackerRecHitRef > FastTrackerRecHitCombination
Definition: FastTrackerRecHitCollection.h:11
TrajectorySeedProducer::hitMasksToken
edm::EDGetTokenT< std::vector< bool > > hitMasksToken
Definition: TrajectorySeedProducer.cc:64
SeedCreator.h
Exception
Definition: hltDiff.cc:245
TrackingLayer::createFromString
static TrackingLayer createFromString(std::string layerSpecification)
Definition: TrackingLayer.cc:79
EventSetup.h
edm::ParameterSet::getParameter
T getParameter(std::string const &) const
Definition: ParameterSet.h:303
TrajectorySeedProducer::TrajectorySeedProducer
TrajectorySeedProducer(const edm::ParameterSet &conf)
Definition: TrajectorySeedProducer.cc:87
edm::OwnVector::push_back
void push_back(D *&d)
Definition: OwnVector.h:326
SeedingNode
Definition: SeedingTree.h:10
AlignmentPI::regions
regions
Definition: AlignmentPayloadInspectorHelper.h:78
ConsumesCollector.h
TrackingRegion.h
TrackerTopologyRcd
Definition: TrackerTopologyRcd.h:10
ParameterSet.h
OwnVector.h
edm::Event
Definition: Event.h:73
mps_splice.line
line
Definition: mps_splice.py:76
edm::OwnVector::size
size_type size() const
Definition: OwnVector.h:300
edm::InputTag
Definition: InputTag.h:15
edm::OwnVector
Definition: OwnVector.h:24
MillePedeFileConverter_cfg.e
e
Definition: MillePedeFileConverter_cfg.py:37