CMS 3D CMS Logo

List of all members | Public Member Functions | Private Attributes
ME0SegmentBuilder Class Reference

#include <ME0SegmentBuilder.h>

Public Member Functions

void build (const ME0RecHitCollection *rechits, ME0SegmentCollection &oc)
 
 ME0SegmentBuilder (const edm::ParameterSet &)
 
void setGeometry (const ME0Geometry *g)
 
 ~ME0SegmentBuilder ()
 Destructor. More...
 

Private Attributes

std::unique_ptr< ME0SegmentAlgorithmBasealgo
 
const ME0Geometrygeom_
 

Detailed Description

CSCSegmentBuilder Algorithm to build ME0Segment's from ME0RecHit collection by implementing a 'build' function required by ME0SegmentProducer.

Implementation notes:
Configured via the Producer's ParameterSet.
Presume this might become an abstract base class one day.

Date
2014/02/04 13:45:31
Revision
1.1
Author
Marcello Maggi

Definition at line 25 of file ME0SegmentBuilder.h.

Constructor & Destructor Documentation

◆ ME0SegmentBuilder()

ME0SegmentBuilder::ME0SegmentBuilder ( const edm::ParameterSet ps)
explicit

Configure the algorithm via ctor. Receives ParameterSet percolated down from EDProducer which owns this Builder.

Definition at line 13 of file ME0SegmentBuilder.cc.

13  : geom_(nullptr) {
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 }

References algo, MillePedeAlignmentAlgorithm_cfi::algoName, get, edm::ParameterSet::getParameter(), LogDebug, and AlCaHLTBitMon_QueryRunRegistry::string.

◆ ~ME0SegmentBuilder()

ME0SegmentBuilder::~ME0SegmentBuilder ( )

Destructor.

Definition at line 28 of file ME0SegmentBuilder.cc.

28 {}

Member Function Documentation

◆ build()

void ME0SegmentBuilder::build ( const ME0RecHitCollection rechits,
ME0SegmentCollection oc 
)

Find rechits in each ensemble of all ME0 layers, build ME0Segment's , and fill into output collection.

Definition at line 30 of file ME0SegmentBuilder.cc.

30  {
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 }

References algo, ME0Geometry::chamber(), relativeConstraints::chamber, ME0Geometry::etaPartition(), geom_, glb, ME0SegmentAlgorithmBase::HitAndPosition::layer, phase1PixelTopology::layer, LogDebug, FastTrackerRecHitMaskProducer_cfi::recHits, and jetUpdater_cfi::sort.

◆ setGeometry()

void ME0SegmentBuilder::setGeometry ( const ME0Geometry g)

Cache pointer to geometry for current event

Definition at line 85 of file ME0SegmentBuilder.cc.

85 { geom_ = geom; }

References relativeConstraints::geom, and geom_.

Member Data Documentation

◆ algo

std::unique_ptr<ME0SegmentAlgorithmBase> ME0SegmentBuilder::algo
private

Definition at line 45 of file ME0SegmentBuilder.h.

Referenced by build(), and ME0SegmentBuilder().

◆ geom_

const ME0Geometry* ME0SegmentBuilder::geom_
private

Definition at line 46 of file ME0SegmentBuilder.h.

Referenced by build(), and setGeometry().

ME0SegmentAlgorithmBase::HitAndPositionContainer
std::vector< HitAndPosition > HitAndPositionContainer
Definition: ME0SegmentAlgorithmBase.h:35
ME0SegmentBuilder::geom_
const ME0Geometry * geom_
Definition: ME0SegmentBuilder.h:46
ME0Geometry::chamber
const ME0Chamber * chamber(ME0DetId id) const
Return a chamber given its id.
Definition: ME0Geometry.cc:43
part
part
Definition: HCALResponse.h:20
MillePedeAlignmentAlgorithm_cfi.algoName
algoName
Definition: MillePedeAlignmentAlgorithm_cfi.py:10
relativeConstraints.geom
geom
Definition: relativeConstraints.py:72
Point3DBase< float, GlobalTag >
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
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
ME0SegmentBuilder::algo
std::unique_ptr< ME0SegmentAlgorithmBase > algo
Definition: ME0SegmentBuilder.h:45
relativeConstraints.chamber
chamber
Definition: relativeConstraints.py:53
edm::ParameterSet::getParameter
T getParameter(std::string const &) const
Definition: ParameterSet.h:303
ME0Geometry::etaPartition
const ME0EtaPartition * etaPartition(ME0DetId id) const
Return a etaPartition given its id.
Definition: ME0Geometry.cc:35
glb
double glb
Definition: hdecay.h:103
ME0SegmentAlgorithmBase::HitAndPosition
Definition: ME0SegmentAlgorithmBase.h:25
ME0SegmentAlgorithmBase::HitAndPosition::layer
unsigned int layer
Definition: ME0SegmentAlgorithmBase.h:31