CMS 3D CMS Logo

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