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 ( 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.

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

13  : geom_(nullptr) {
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 }
#define LogDebug(id)
T getParameter(std::string const &) const
std::unique_ptr< ME0SegmentAlgorithmBase > algo
const ME0Geometry * geom_
T get(const Candidate &c)
Definition: component.h:55
ME0SegmentBuilder::~ME0SegmentBuilder ( )

Destructor.

Definition at line 29 of file ME0SegmentBuilder.cc.

29 {}

Member Function Documentation

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 31 of file ME0SegmentBuilder.cc.

References algo, ME0Geometry::chamber(), relativeConstraints::chamber, ME0Geometry::etaPartition(), geom_, glb, ME0SegmentAlgorithmBase::HitAndPosition::layer, ME0Chamber::layers(), LogDebug, GeomDet::position(), jetUpdater_cfi::sort, GeomDet::toLocal(), and PV3DBase< T, PVType, FrameType >::z().

31  {
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 }
#define LogDebug(id)
double glb
Definition: hdecay.h:105
LocalPoint toLocal(const GlobalPoint &gp) const
Conversion to the R.F. of the GeomDet.
Definition: GeomDet.h:69
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
T z() const
Definition: PV3DBase.h:64
const ME0Chamber * chamber(ME0DetId id) const
Return a chamber given its id.
Definition: ME0Geometry.cc:73
part
Definition: HCALResponse.h:20
std::unique_ptr< ME0SegmentAlgorithmBase > algo
const ME0Geometry * geom_
const std::vector< const ME0Layer * > & layers() const
Return the layers.
Definition: ME0Chamber.cc:34
void ME0SegmentBuilder::setGeometry ( const ME0Geometry g)

Cache pointer to geometry for current event

Definition at line 81 of file ME0SegmentBuilder.cc.

References relativeConstraints::geom, and geom_.

81  {
82  geom_ = geom;
83 }
const ME0Geometry * geom_

Member Data Documentation

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

Definition at line 46 of file ME0SegmentBuilder.h.

Referenced by build(), and ME0SegmentBuilder().

const ME0Geometry* ME0SegmentBuilder::geom_
private

Definition at line 47 of file ME0SegmentBuilder.h.

Referenced by build(), and setGeometry().