CMS 3D CMS Logo

ME0SegmentBuilder.cc
Go to the documentation of this file.
9 
12 
14  // Algo type (indexed)
15  int chosenAlgo = ps.getParameter<int>("algo_type") - 1;
16  // Find appropriate ParameterSets for each algo type
17 
18  std::vector<edm::ParameterSet> algoPSets = ps.getParameter<std::vector<edm::ParameterSet> >("algo_psets");
19 
20  edm::ParameterSet segAlgoPSet = algoPSets[chosenAlgo].getParameter<edm::ParameterSet>("algo_pset");
21  std::string algoName = algoPSets[chosenAlgo].getParameter<std::string>("algo_name");
22  LogDebug("ME0SegmentBuilder") << "ME0SegmentBuilder algorithm name: " << algoName;
23 
24  // Ask factory to build this algorithm, giving it appropriate ParameterSet
25  algo = ME0SegmentBuilderPluginFactory::get()->create(algoName, segAlgoPSet);
26 }
27 
29 
31  LogDebug("ME0SegmentBuilder") << "Total number of rechits in this event: " << recHits->size();
32 
33  std::map<ME0DetId, bool> foundChambers;
34  for (ME0RecHitCollection::const_iterator it = recHits->begin(); it != recHits->end(); it++) {
35  const auto chId = it->me0Id().chamberId();
36  auto chIt = foundChambers.find(chId);
37  if (chIt != foundChambers.end())
38  continue;
39  foundChambers[chId] = true;
41  const ME0Chamber* chamber = geom_->chamber(chId);
42  for (ME0RecHitCollection::const_iterator it2 = it; it2 != recHits->end(); it2++) {
43  if (it2->me0Id().chamberId() != chId)
44  continue;
45 
46  const auto* part = geom_->etaPartition(it2->me0Id());
47  GlobalPoint glb = part->toGlobal(it2->localPosition());
48  LocalPoint nLoc = chamber->toLocal(glb);
49  hitAndPositions.emplace_back(&(*it2), nLoc, glb, hitAndPositions.size());
50  }
51 
52  LogDebug("ME0Segment|ME0") << "found " << hitAndPositions.size() << " rechits in chamber " << chId;
53  //sort by layer
54  auto getLayer = [&](int iL) -> const ME0Layer* { //function is broken in the geo currently
55  for (auto layer : chamber->layers()) {
56  if (layer->id().layer() == iL)
57  return layer;
58  }
59  return nullptr;
60  };
61  float z1 = getLayer(1)->position().z();
62  float z6 = getLayer(6)->position().z();
63  if (z1 < z6)
64  std::sort(hitAndPositions.begin(),
65  hitAndPositions.end(),
67  const ME0SegmentAlgorithmBase::HitAndPosition& h2) { return h1.layer < h2.layer; });
68  else
69  std::sort(hitAndPositions.begin(),
70  hitAndPositions.end(),
72  const ME0SegmentAlgorithmBase::HitAndPosition& h2) { return h1.layer > h2.layer; });
73 
74  // given the chamber select the appropriate algo... and run it
75  std::vector<ME0Segment> segv = algo->run(chamber, hitAndPositions);
76 
77  LogDebug("ME0Segment|ME0") << "found " << segv.size() << " segments in chamber " << chId;
78 
79  // Add the segments to master collection
80  if (!segv.empty())
81  oc.put(chId, segv.begin(), segv.end());
82  }
83 }
84 
ME0RecHit.h
ME0SegmentBuilder::ME0SegmentBuilder
ME0SegmentBuilder(const edm::ParameterSet &)
Definition: ME0SegmentBuilder.cc:13
MessageLogger.h
ME0SegmentAlgorithmBase::HitAndPositionContainer
std::vector< HitAndPosition > HitAndPositionContainer
Definition: ME0SegmentAlgorithmBase.h:35
ME0Geometry
Definition: ME0Geometry.h:12
ME0DetId.h
ME0SegmentBuilder::geom_
const ME0Geometry * geom_
Definition: ME0SegmentBuilder.h:46
ME0SegmentBuilderPluginFactory.h
ME0Geometry::chamber
const ME0Chamber * chamber(ME0DetId id) const
Return a chamber given its id.
Definition: ME0Geometry.cc:43
part
part
Definition: HCALResponse.h:20
ME0SegmentBuilder::build
void build(const ME0RecHitCollection *rechits, ME0SegmentCollection &oc)
Definition: ME0SegmentBuilder.cc:30
MillePedeAlignmentAlgorithm_cfi.algoName
algoName
Definition: MillePedeAlignmentAlgorithm_cfi.py:10
relativeConstraints.geom
geom
Definition: relativeConstraints.py:72
Point3DBase< float, GlobalTag >
ME0SegmentBuilder::setGeometry
void setGeometry(const ME0Geometry *g)
Definition: ME0SegmentBuilder.cc:85
phase1PixelTopology::layer
constexpr std::array< uint8_t, layerIndexSize > layer
Definition: phase1PixelTopology.h:99
FastTrackerRecHitMaskProducer_cfi.recHits
recHits
Definition: FastTrackerRecHitMaskProducer_cfi.py:8
LogDebug
#define LogDebug(id)
Definition: MessageLogger.h:233
edm::ParameterSet
Definition: ParameterSet.h:47
ME0SegmentBuilder::~ME0SegmentBuilder
~ME0SegmentBuilder()
Destructor.
Definition: ME0SegmentBuilder.cc:28
jetUpdater_cfi.sort
sort
Definition: jetUpdater_cfi.py:29
ME0Layer
Definition: ME0Layer.h:9
edm::RangeMap::const_iterator
C::const_iterator const_iterator
constant access iterator type
Definition: RangeMap.h:43
ME0Chamber
Definition: ME0Chamber.h:10
get
#define get
AlCaHLTBitMon_QueryRunRegistry.string
string string
Definition: AlCaHLTBitMon_QueryRunRegistry.py:256
ME0RecHitCollection
ME0Geometry.h
ME0SegmentAlgorithmBase.h
ME0SegmentBuilder::algo
std::unique_ptr< ME0SegmentAlgorithmBase > algo
Definition: ME0SegmentBuilder.h:45
ME0EtaPartition.h
relativeConstraints.chamber
chamber
Definition: relativeConstraints.py:53
edm::ParameterSet::getParameter
T getParameter(std::string const &) const
Definition: ParameterSet.h:303
Exception.h
ME0SegmentBuilder.h
ME0Geometry::etaPartition
const ME0EtaPartition * etaPartition(ME0DetId id) const
Return a etaPartition given its id.
Definition: ME0Geometry.cc:35
ME0Chamber.h
glb
double glb
Definition: hdecay.h:103
ME0SegmentCollection
ME0SegmentAlgorithmBase::HitAndPosition
Definition: ME0SegmentAlgorithmBase.h:25
ME0SegmentAlgorithmBase::HitAndPosition::layer
unsigned int layer
Definition: ME0SegmentAlgorithmBase.h:31