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 
#define LogDebug(id)
T getParameter(std::string const &) const
double glb
Definition: hdecay.h:103
#define nullptr
LocalPoint toLocal(const GlobalPoint &gp) const
Conversion to the R.F. of the GeomDet.
Definition: GeomDet.h:58
ME0SegmentBuilder(const edm::ParameterSet &)
const ME0EtaPartition * etaPartition(ME0DetId id) const
Return a etaPartition given its id.
Definition: ME0Geometry.cc:35
std::vector< HitAndPosition > HitAndPositionContainer
C::const_iterator const_iterator
constant access iterator type
Definition: RangeMap.h:43
const Surface::PositionType & position() const
The position (origin of the R.F.)
Definition: GeomDet.h:43
void setGeometry(const ME0Geometry *g)
T z() const
Definition: PV3DBase.h:61
const ME0Chamber * chamber(ME0DetId id) const
Return a chamber given its id.
Definition: ME0Geometry.cc:43
void build(const ME0RecHitCollection *rechits, ME0SegmentCollection &oc)
part
Definition: HCALResponse.h:20
~ME0SegmentBuilder()
Destructor.
std::unique_ptr< ME0SegmentAlgorithmBase > algo
const ME0Geometry * geom_
const std::vector< const ME0Layer * > & layers() const
Return the layers.
Definition: ME0Chamber.cc:24