CMS 3D CMS Logo

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

#include <CSCSegmentBuilder.h>

Public Member Functions

void build (const CSCRecHit2DCollection *rechits, CSCSegmentCollection &oc)
 
 CSCSegmentBuilder (const edm::ParameterSet &)
 
void setGeometry (const CSCGeometry *geom)
 
 ~CSCSegmentBuilder ()
 Destructor. More...
 

Private Attributes

std::map< std::string, CSCSegmentAlgorithm * > algoMap
 
const CSCGeometrygeom_
 

Detailed Description

Algorithm to build CSCSegment's from CSCRecHit2D collection by implementing a 'build' function required by CSCSegmentProducer.

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

Author
M. Sani

Definition at line 25 of file CSCSegmentBuilder.h.

Constructor & Destructor Documentation

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

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

Definition at line 21 of file CSCSegmentBuilder.cc.

References algoMap, HIPAlignmentAlgorithm_cfi::algoName, beamerCreator::create(), Exception, reco::get(), edm::ParameterSet::getParameter(), LogDebug, and AlCaHLTBitMon_QueryRunRegistry::string.

21  : geom_(nullptr) {
22 
23  // The algo chosen for the segment building
24  int chosenAlgo = ps.getParameter<int>("algo_type") - 1;
25 
26  // Find appropriate ParameterSets for each algo type
27  std::vector<edm::ParameterSet> algoPSets = ps.getParameter<std::vector<edm::ParameterSet> >("algo_psets");
28 
29  // Now load the right parameter set
30  // Algo name
31  std::string algoName = algoPSets[chosenAlgo].getParameter<std::string>("algo_name");
32 
33  LogDebug("CSCSegment|CSC")<< "CSCSegmentBuilder algorithm name: " << algoName;
34 
35  // SegAlgo parameter set
36  std::vector<edm::ParameterSet> segAlgoPSet = algoPSets[chosenAlgo].getParameter<std::vector<edm::ParameterSet> >("algo_psets");
37 
38  // Chamber types to handle
39  std::vector<std::string> chType = algoPSets[chosenAlgo].getParameter<std::vector<std::string> >("chamber_types");
40  LogDebug("CSCSegment|CSC")<< "No. of chamber types to handle: " << chType.size();
41 
42  // Algo to chamber type
43  std::vector<int> algoToType = algoPSets[chosenAlgo].getParameter<std::vector<int> >("parameters_per_chamber_type");
44 
45  // Trap if we don't have enough parameter sets or haven't assigned an algo to every type
46  if (algoToType.size() != chType.size()) {
47  throw cms::Exception("ParameterSetError") <<
48  "#dim algosToType=" << algoToType.size() << ", #dim chType=" << chType.size() << std::endl;
49  }
50 
51  // Ask factory to build this algorithm, giving it appropriate ParameterSet
52 
53  for (size_t j=0; j<chType.size(); ++j) {
55  create(algoName, segAlgoPSet[algoToType[j]-1]);
56  edm::LogVerbatim("CSCSegment|CSC")<< "using algorithm #" << algoToType[j] << " for chamber type " << chType[j];
57  }
58 }
#define LogDebug(id)
T getParameter(std::string const &) const
def create(alignables, pedeDump, additionalData, outputFile, config)
std::map< std::string, CSCSegmentAlgorithm * > algoMap
const CSCGeometry * geom_
T get(const Candidate &c)
Definition: component.h:55
CSCSegmentBuilder::~CSCSegmentBuilder ( )

Destructor.

Definition at line 60 of file CSCSegmentBuilder.cc.

References algoMap.

60  {
61  //
62  // loop on algomap and delete them
63  //
64  for (std::map<std::string, CSCSegmentAlgorithm*>::iterator it = algoMap.begin();it != algoMap.end(); it++){
65  delete ((*it).second);
66  }
67 }
std::map< std::string, CSCSegmentAlgorithm * > algoMap

Member Function Documentation

void CSCSegmentBuilder::build ( const CSCRecHit2DCollection rechits,
CSCSegmentCollection oc 
)

Find rechits in each CSCChamber, build CSCSegment's in each chamber, and fill into output collection.

Definition at line 69 of file CSCSegmentBuilder.cc.

References algoMap, relativeConstraints::chamber, CSCGeometry::chamber(), chambers, CSCChamberSpecs::chamberTypeName(), CSCRangeMapAccessor::cscChamber(), geom_, edm::eventsetup::heterocontainer::insert(), LogDebug, and CSCChamber::specs().

Referenced by CSCSegmentProducer::produce().

69  {
70 
71  LogDebug("CSCSegment|CSC")<< "Total number of rechits in this event: " << recHits->size();
72 
73  std::vector<CSCDetId> chambers;
74  std::vector<CSCDetId>::const_iterator chIt;
75 
76  for(CSCRecHit2DCollection::const_iterator it2 = recHits->begin(); it2 != recHits->end(); it2++) {
77 
78  bool insert = true;
79  for(chIt=chambers.begin(); chIt != chambers.end(); ++chIt)
80  if (((*it2).cscDetId().chamber() == (*chIt).chamber()) &&
81  ((*it2).cscDetId().station() == (*chIt).station()) &&
82  ((*it2).cscDetId().ring() == (*chIt).ring()) &&
83  ((*it2).cscDetId().endcap() == (*chIt).endcap()))
84  insert = false;
85 
86  if (insert)
87  chambers.push_back((*it2).cscDetId().chamberId());
88  }
89 
90  for(chIt=chambers.begin(); chIt != chambers.end(); ++chIt) {
91 
92  std::vector<const CSCRecHit2D*> cscRecHits;
93  const CSCChamber* chamber = geom_->chamber(*chIt);
94 
96  CSCRecHit2DCollection::range range = recHits->get(acc.cscChamber(*chIt));
97 
98  std::vector<int> hitPerLayer(6);
99  for(CSCRecHit2DCollection::const_iterator rechit = range.first; rechit != range.second; rechit++) {
100 
101  hitPerLayer[(*rechit).cscDetId().layer()-1]++;
102  cscRecHits.push_back(&(*rechit));
103  }
104 
105  LogDebug("CSCSegment|CSC") << "found " << cscRecHits.size() << " rechits in chamber " << *chIt;
106 
107  // given the chamber select the appropriate algo... and run it
108  std::vector<CSCSegment> segv = algoMap[chamber->specs()->chamberTypeName()]->run(chamber, cscRecHits);
109 
110  LogDebug("CSCSegment|CSC") << "found " << segv.size() << " segments in chamber " << *chIt;
111 
112  // Add the segments to master collection
113  oc.put((*chIt), segv.begin(), segv.end());
114  }
115 }
#define LogDebug(id)
std::pair< const_iterator, const_iterator > range
iterator range
Definition: RangeMap.h:50
std::map< std::string, CSCSegmentAlgorithm * > algoMap
std::string chamberTypeName() const
const CSCGeometry * geom_
const CSCChamberSpecs * specs() const
Definition: CSCChamber.h:42
bool insert(Storage &iStorage, ItemType *iItem, const IdTag &iIdTag)
Definition: HCMethods.h:49
const CSCChamber * chamber(CSCDetId id) const
Return the chamber corresponding to given DetId.
Definition: CSCGeometry.cc:133
static char chambers[264][20]
Definition: ReadPGInfo.cc:243
static std::pair< CSCDetId, CSCDetIdSameChamberComparator > cscChamber(CSCDetId id)
Returns a valid DetId + a valid comparator for the RangeMap.
void CSCSegmentBuilder::setGeometry ( const CSCGeometry geom)

Cache pointer to geometry for current event

Definition at line 117 of file CSCSegmentBuilder.cc.

References relativeConstraints::geom, and geom_.

Referenced by CSCSegmentProducer::produce().

117  {
118  geom_ = geom;
119 }
const CSCGeometry * geom_

Member Data Documentation

std::map<std::string, CSCSegmentAlgorithm*> CSCSegmentBuilder::algoMap
private

Definition at line 48 of file CSCSegmentBuilder.h.

Referenced by build(), CSCSegmentBuilder(), and ~CSCSegmentBuilder().

const CSCGeometry* CSCSegmentBuilder::geom_
private

Definition at line 47 of file CSCSegmentBuilder.h.

Referenced by build(), and setGeometry().