#include <CSCSegmentBuilder.h>
Public Member Functions | |
void | build (const CSCRecHit2DCollection *rechits, CSCSegmentCollection &oc) |
CSCSegmentBuilder (const edm::ParameterSet &) | |
void | setGeometry (const CSCGeometry *geom) |
~CSCSegmentBuilder () | |
Destructor. | |
Private Attributes | |
std::map< std::string, CSCSegmentAlgorithm * > | algoMap |
const CSCGeometry * | geom_ |
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.
Definition at line 27 of file CSCSegmentBuilder.h.
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, SurfaceDeformationFactory::create(), Exception, reco::get(), edm::ParameterSet::getParameter(), j, and LogDebug.
: geom_(0) { // The algo chosen for the segment building int chosenAlgo = ps.getParameter<int>("algo_type") - 1; // Find appropriate ParameterSets for each algo type std::vector<edm::ParameterSet> algoPSets = ps.getParameter<std::vector<edm::ParameterSet> >("algo_psets"); // Now load the right parameter set // Algo name std::string algoName = algoPSets[chosenAlgo].getParameter<std::string>("algo_name"); LogDebug("CSCSegment|CSC")<< "CSCSegmentBuilder algorithm name: " << algoName; // SegAlgo parameter set std::vector<edm::ParameterSet> segAlgoPSet = algoPSets[chosenAlgo].getParameter<std::vector<edm::ParameterSet> >("algo_psets"); // Chamber types to handle std::vector<std::string> chType = algoPSets[chosenAlgo].getParameter<std::vector<std::string> >("chamber_types"); LogDebug("CSCSegment|CSC")<< "No. of chamber types to handle: " << chType.size(); // Algo to chamber type std::vector<int> algoToType = algoPSets[chosenAlgo].getParameter<std::vector<int> >("parameters_per_chamber_type"); // Trap if we don't have enough parameter sets or haven't assigned an algo to every type if (algoToType.size() != chType.size()) { throw cms::Exception("ParameterSetError") << "#dim algosToType=" << algoToType.size() << ", #dim chType=" << chType.size() << std::endl; } // Ask factory to build this algorithm, giving it appropriate ParameterSet for (size_t j=0; j<chType.size(); ++j) { algoMap[chType[j]] = CSCSegmentBuilderPluginFactory::get()-> create(algoName, segAlgoPSet[algoToType[j]-1]); LogDebug("CSCSegment|CSC")<< "using algorithm #" << algoToType[j] << " for chamber type " << chType[j]; } }
CSCSegmentBuilder::~CSCSegmentBuilder | ( | ) |
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, CSCGeometry::chamber(), chambers, CSCChamberSpecs::chamberTypeName(), CSCRangeMapAccessor::cscChamber(), geom_, edm::eventsetup::heterocontainer::insert(), LogDebug, and CSCChamber::specs().
Referenced by CSCSegmentProducer::produce().
{ LogDebug("CSCSegment|CSC")<< "Total number of rechits in this event: " << recHits->size(); std::vector<CSCDetId> chambers; std::vector<CSCDetId>::const_iterator chIt; for(CSCRecHit2DCollection::const_iterator it2 = recHits->begin(); it2 != recHits->end(); it2++) { bool insert = true; for(chIt=chambers.begin(); chIt != chambers.end(); ++chIt) if (((*it2).cscDetId().chamber() == (*chIt).chamber()) && ((*it2).cscDetId().station() == (*chIt).station()) && ((*it2).cscDetId().ring() == (*chIt).ring()) && ((*it2).cscDetId().endcap() == (*chIt).endcap())) insert = false; if (insert) chambers.push_back((*it2).cscDetId().chamberId()); } for(chIt=chambers.begin(); chIt != chambers.end(); ++chIt) { std::vector<const CSCRecHit2D*> cscRecHits; const CSCChamber* chamber = geom_->chamber(*chIt); CSCRangeMapAccessor acc; CSCRecHit2DCollection::range range = recHits->get(acc.cscChamber(*chIt)); std::vector<int> hitPerLayer(6); for(CSCRecHit2DCollection::const_iterator rechit = range.first; rechit != range.second; rechit++) { hitPerLayer[(*rechit).cscDetId().layer()-1]++; cscRecHits.push_back(&(*rechit)); } LogDebug("CSCSegment|CSC") << "found " << cscRecHits.size() << " rechits in chamber " << *chIt; // given the chamber select the appropriate algo... and run it std::vector<CSCSegment> segv = algoMap[chamber->specs()->chamberTypeName()]->run(chamber, cscRecHits); LogDebug("CSCSegment|CSC") << "found " << segv.size() << " segments in chamber " << *chIt; // Add the segments to master collection oc.put((*chIt), segv.begin(), segv.end()); } }
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().
std::map<std::string, CSCSegmentAlgorithm*> CSCSegmentBuilder::algoMap [private] |
Definition at line 50 of file CSCSegmentBuilder.h.
Referenced by build(), CSCSegmentBuilder(), and ~CSCSegmentBuilder().
const CSCGeometry* CSCSegmentBuilder::geom_ [private] |
Definition at line 49 of file CSCSegmentBuilder.h.
Referenced by build(), and setGeometry().