CMS 3D CMS Logo

MultiHitFromChi2EDProducer.cc
Go to the documentation of this file.
10 
16 
18 public:
20  ~MultiHitFromChi2EDProducer() override = default;
21 
22  static void fillDescriptions(edm::ConfigurationDescriptions& descriptions);
23 
24  void produce(edm::Event& iEvent, const edm::EventSetup& iSetup) override;
25 
26 private:
28 
30 
32 };
33 
35  : doubletToken_(consumes<IntermediateHitDoublets>(iConfig.getParameter<edm::InputTag>("doublets"))),
36  generator_(iConfig) {
37  produces<RegionsSeedingHitSets>();
38  produces<edm::OwnVector<BaseTrackerRecHit> >();
39 }
40 
43 
44  desc.add<edm::InputTag>("doublets", edm::InputTag("hitPairEDProducer"));
45 
47 
49  descriptions.add(label, desc);
50 }
51 
54  iEvent.getByToken(doubletToken_, hdoublets);
55  const auto& regionDoublets = *hdoublets;
56 
57  const SeedingLayerSetsHits& seedingLayerHits = regionDoublets.seedingLayerHits();
58  if (seedingLayerHits.numberOfLayersInSet() < 3) {
59  throw cms::Exception("LogicError")
60  << "MultiHitFromChi2EDProducer expects SeedingLayerSetsHits::numberOfLayersInSet() to be >= 3, got "
61  << seedingLayerHits.numberOfLayersInSet()
62  << ". This is likely caused by a configuration error of this module, HitPairEDProducer, or "
63  "SeedingLayersEDProducer.";
64  }
65 
66  auto seedingHitSets = std::make_unique<RegionsSeedingHitSets>();
67  if (regionDoublets.empty()) {
69  return;
70  }
71  seedingHitSets->reserve(regionDoublets.regionSize(), localRA_.upper());
72  generator_.initES(iSetup);
73 
74  // match-making of pair and triplet layers
75  std::vector<LayerTriplets::LayerSetAndLayers> trilayers = LayerTriplets::layers(seedingLayerHits);
76 
77  OrderedMultiHits multihits;
78  multihits.reserve(localRA_.upper());
79  std::vector<std::unique_ptr<BaseTrackerRecHit> > refittedHitStorage;
80  refittedHitStorage.reserve(localRA_.upper() * 2);
81 
82  LogDebug("MultiHitFromChi2EDProducer") << "Creating multihits for " << regionDoublets.regionSize() << " regions, and "
83  << trilayers.size() << " pair+3rd layers from "
84  << regionDoublets.layerPairsSize() << " layer pairs";
85 
86  LayerHitMapCache hitCache;
87  for (const auto& regionLayerPairs : regionDoublets) {
88  const TrackingRegion& region = regionLayerPairs.region();
89 
90  auto seedingHitSetsFiller = RegionsSeedingHitSets::dummyFiller();
91  seedingHitSetsFiller = seedingHitSets->beginRegion(&region);
92 
93  hitCache.clear();
94  hitCache.extend(regionLayerPairs.layerHitMapCache());
95 
96  LogTrace("MultiHitFromChi2EDProducer") << " starting region";
97 
98  for (const auto& layerPair : regionLayerPairs) {
99  LogTrace("MultiHitFromChi2EDProducer")
100  << " starting layer pair " << layerPair.innerLayerIndex() << "," << layerPair.outerLayerIndex();
101 
102  auto found = std::find_if(trilayers.begin(), trilayers.end(), [&](const LayerTriplets::LayerSetAndLayers& a) {
103  return a.first[0].index() == layerPair.innerLayerIndex() && a.first[1].index() == layerPair.outerLayerIndex();
104  });
105  if (found == trilayers.end()) {
106  auto exp = cms::Exception("LogicError") << "Did not find the layer pair from vector<pair+third layers>. This "
107  "is a sign of some internal inconsistency\n";
108  exp << "I was looking for layer pair " << layerPair.innerLayerIndex() << "," << layerPair.outerLayerIndex()
109  << ". Triplets have the following pairs:\n";
110  for (const auto& a : trilayers) {
111  exp << " " << a.first[0].index() << "," << a.first[1].index() << ": 3rd layers";
112  for (const auto& b : a.second) {
113  exp << " " << b.index();
114  }
115  exp << "\n";
116  }
117  throw exp;
118  }
119  const auto& thirdLayers = found->second;
120 
122  region, multihits, iEvent, iSetup, layerPair.doublets(), thirdLayers, hitCache, refittedHitStorage);
123 
124 #ifdef EDM_ML_DEBUG
125  LogTrace("MultiHitFromChi2EDProducer")
126  << " created " << multihits.size() << " multihits for layer pair " << layerPair.innerLayerIndex() << ","
127  << layerPair.outerLayerIndex() << " and 3rd layers";
128  for (const auto& l : thirdLayers) {
129  LogTrace("MultiHitFromChi2EDProducer") << " " << l.index();
130  }
131 #endif
132 
133  for (const SeedingHitSet& hitSet : multihits) {
134  seedingHitSetsFiller.emplace_back(hitSet);
135  }
136  multihits.clear();
137  }
138  }
139  localRA_.update(seedingHitSets->size());
140 
141  auto storage = std::make_unique<edm::OwnVector<BaseTrackerRecHit> >();
142  storage->reserve(refittedHitStorage.size());
143  for (auto& ptr : refittedHitStorage)
144  storage->push_back(ptr.release());
145 
146  seedingHitSets->shrink_to_fit();
147  storage->shrink_to_fit();
149  iEvent.put(std::move(storage));
150 }
151 
ConfigurationDescriptions.h
RunningAverage.h
Handle.h
OrderedMultiHits
Definition: OrderedMultiHits.h:8
SeedingHitSet
Definition: SeedingHitSet.h:6
edm::EDGetTokenT< IntermediateHitDoublets >
MultiHitGeneratorFromChi2.h
edm
HLT enums.
Definition: AlignableModifier.h:19
HLT_FULL_cff.InputTag
InputTag
Definition: HLT_FULL_cff.py:89301
edm::ParameterSetDescription
Definition: ParameterSetDescription.h:52
SeedingLayerSetsHits
Definition: SeedingLayerSetsHits.h:18
MultiHitFromChi2EDProducer
Definition: MultiHitFromChi2EDProducer.cc:17
EDProducer.h
IntermediateHitDoublets.h
LayerHitMapCache::extend
void extend(const LayerHitMapCache &other)
Definition: LayerHitMapCache.h:71
MultiHitFromChi2EDProducer::doubletToken_
edm::EDGetTokenT< IntermediateHitDoublets > doubletToken_
Definition: MultiHitFromChi2EDProducer.cc:27
newFWLiteAna.found
found
Definition: newFWLiteAna.py:118
edm::Handle
Definition: AssociativeIterator.h:50
MakerMacros.h
LayerHitMapCache
Definition: LayerHitMapCache.h:14
DEFINE_FWK_MODULE
#define DEFINE_FWK_MODULE(type)
Definition: MakerMacros.h:16
edm::ConfigurationDescriptions::add
void add(std::string const &label, ParameterSetDescription const &psetDescription)
Definition: ConfigurationDescriptions.cc:57
MultiHitGeneratorFromChi2
Definition: MultiHitGeneratorFromChi2.h:29
HLT_FULL_cff.seedingHitSets
seedingHitSets
Definition: HLT_FULL_cff.py:10133
MultiHitGeneratorFromChi2::fillDescriptionsLabel
static const char * fillDescriptionsLabel()
Definition: MultiHitGeneratorFromChi2.h:38
edm::RunningAverage::update
void update(unsigned int q)
Definition: RunningAverage.h:35
ParameterSetDescription.h
b
double b
Definition: hdecay.h:118
EDGetToken.h
SeedingLayerSetsHits::numberOfLayersInSet
unsigned short numberOfLayersInSet() const
Get number of layers in each SeedingLayerSets.
Definition: SeedingLayerSetsHits.h:197
edm::ConfigurationDescriptions
Definition: ConfigurationDescriptions.h:28
RegionsSeedingHitSets::dummyFiller
static RegionFiller dummyFiller()
Definition: RegionsSeedingHitSets.h:46
MultiHitFromChi2EDProducer::localRA_
edm::RunningAverage localRA_
Definition: MultiHitFromChi2EDProducer.cc:29
LogDebug
#define LogDebug(id)
Definition: MessageLogger.h:233
edm::ParameterSet
Definition: ParameterSet.h:47
a
double a
Definition: hdecay.h:119
Event.h
OrderedMultiHits::size
unsigned int size() const override
Definition: OrderedMultiHits.h:12
MultiHitFromChi2EDProducer::produce
void produce(edm::Event &iEvent, const edm::EventSetup &iSetup) override
Definition: MultiHitFromChi2EDProducer.cc:52
HLT_FULL_cff.region
region
Definition: HLT_FULL_cff.py:88286
ModuleDef.h
iEvent
int iEvent
Definition: GenABIO.cc:224
IntermediateHitDoublets
Definition: IntermediateHitDoublets.h:131
edm::stream::EDProducer
Definition: EDProducer.h:36
edm::EventSetup
Definition: EventSetup.h:58
RegionsSeedingHitSets.h
AlCaHLTBitMon_QueryRunRegistry.string
string string
Definition: AlCaHLTBitMon_QueryRunRegistry.py:256
MultiHitFromChi2EDProducer::MultiHitFromChi2EDProducer
MultiHitFromChi2EDProducer(const edm::ParameterSet &iConfig)
Definition: MultiHitFromChi2EDProducer.cc:34
cmsLHEtoEOSManager.l
l
Definition: cmsLHEtoEOSManager.py:204
MultiHitGeneratorFromChi2::fillDescriptions
static void fillDescriptions(edm::ParameterSetDescription &desc)
Definition: MultiHitGeneratorFromChi2.cc:105
MultiHitFromChi2EDProducer::fillDescriptions
static void fillDescriptions(edm::ConfigurationDescriptions &descriptions)
Definition: MultiHitFromChi2EDProducer.cc:41
submitPVResolutionJobs.desc
string desc
Definition: submitPVResolutionJobs.py:251
eostools.move
def move(src, dest)
Definition: eostools.py:511
edm::RunningAverage::upper
int upper() const
Definition: RunningAverage.h:30
MultiHitGeneratorFromChi2::hitSets
void hitSets(const TrackingRegion &region, OrderedMultiHits &trs, const edm::Event &ev, const edm::EventSetup &es, SeedingLayerSetsHits::SeedingLayerSet pairLayers, std::vector< SeedingLayerSetsHits::SeedingLayer > thirdLayers) override
Definition: MultiHitGeneratorFromChi2.cc:169
LayerTriplets::LayerSetAndLayers
std::pair< LayerSet, std::vector< Layer > > LayerSetAndLayers
Definition: LayerTriplets.h:16
Exception
Definition: hltDiff.cc:245
LayerTriplets.h
LayerHitMapCache::clear
void clear()
Definition: LayerHitMapCache.h:69
TrackingRegion
Definition: TrackingRegion.h:41
ConsumesCollector.h
LogTrace
#define LogTrace(id)
Definition: MessageLogger.h:234
ParameterSet.h
OwnVector.h
JetChargeProducer_cfi.exp
exp
Definition: JetChargeProducer_cfi.py:6
edm::Event
Definition: Event.h:73
LayerTriplets::layers
std::vector< LayerSetAndLayers > layers(const SeedingLayerSetsHits &sets)
Definition: LayerTriplets.cc:4
MultiHitFromChi2EDProducer::~MultiHitFromChi2EDProducer
~MultiHitFromChi2EDProducer() override=default
edm::InputTag
Definition: InputTag.h:15
label
const char * label
Definition: PFTauDecayModeTools.cc:11
edm::RunningAverage
Definition: RunningAverage.h:17
MultiHitFromChi2EDProducer::generator_
MultiHitGeneratorFromChi2 generator_
Definition: MultiHitFromChi2EDProducer.cc:31
MultiHitGeneratorFromChi2::initES
void initES(const edm::EventSetup &es) override
Definition: MultiHitGeneratorFromChi2.cc:135