CMS 3D CMS Logo

CSCSegmentBuilder Class Reference

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

#include <RecoLocalMuon/CSCSegment/src/CSCSegmentBuilder.h>

List of all members.

Public Member Functions

void build (const CSCRecHit2DCollection *rechits, CSCSegmentCollection &oc)
 Find rechits in each CSCChamber, build CSCSegment's in each chamber, and fill into output collection.
 CSCSegmentBuilder (const edm::ParameterSet &)
 Configure the algorithm via ctor.
void setGeometry (const CSCGeometry *geom)
 Cache pointer to geometry _for current event_.
 ~CSCSegmentBuilder ()
 Destructor.

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.

Date
2006/05/08 17:45:31
Revision
1.3
Author:
M. Sani

Definition at line 27 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 25 of file CSCSegmentBuilder.cc.

References algoMap, lat::endl(), Exception, DBSPlugin::get(), edm::ParameterSet::getParameter(), and j.

00025                                                               : geom_(0) {
00026     
00027     // The algo chosen for the segment building
00028     int chosenAlgo = ps.getParameter<int>("algo_type") - 1;
00029     
00030     // Find appropriate ParameterSets for each algo type
00031     std::vector<edm::ParameterSet> algoPSets = ps.getParameter<std::vector<edm::ParameterSet> >("algo_psets");
00032 
00033     // Now load the right parameter set
00034     // Algo name
00035     std::string algoName = algoPSets[chosenAlgo].getParameter<std::string>("algo_name");
00036         
00037     // SegAlgo parameter set
00038     std::vector<edm::ParameterSet> segAlgoPSet = algoPSets[chosenAlgo].getParameter<std::vector<edm::ParameterSet> >("algo_psets");
00039 
00040     // Chamber types to handle
00041     std::vector<std::string> chType = algoPSets[chosenAlgo].getParameter<std::vector<std::string> >("chamber_types");
00042 
00043     // Algo to chamber type 
00044     std::vector<int> algoToType = algoPSets[chosenAlgo].getParameter<std::vector<int> >("parameters_per_chamber_type");
00045 
00046     // Trap if we don't have enough parameter sets or haven't assigned an algo to every type   
00047     if (algoToType.size() !=  chType.size()) {
00048         throw cms::Exception("ParameterSetError") << 
00049           "#dim algosToType=" << algoToType.size() << ", #dim chType=" << chType.size() << std::endl;
00050     }
00051 
00052     // Ask factory to build this algorithm, giving it appropriate ParameterSet
00053             
00054     for (size_t j=0; j<chType.size(); ++j)              
00055         algoMap[chType[j]] = CSCSegmentBuilderPluginFactory::get()->
00056                 create(algoName, segAlgoPSet[algoToType[j]-1]);
00057 }

CSCSegmentBuilder::~CSCSegmentBuilder (  ) 

Destructor.

Definition at line 59 of file CSCSegmentBuilder.cc.

References algoMap, and it.

00059                                       {
00060   //
00061   // loop on algomap and delete them
00062   //
00063   for (std::map<std::string, CSCSegmentAlgorithm*>::iterator it = algoMap.begin();it != algoMap.end(); it++){
00064     delete ((*it).second);
00065   }
00066 }


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 68 of file CSCSegmentBuilder.cc.

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

Referenced by CSCSegmentProducer::produce().

00068                                                                                             {
00069         
00070     LogDebug("CSC")<< "Total number of RecHits: " << recHits->size() << "\n";
00071 
00072     std::vector<CSCDetId> chambers;
00073     std::vector<CSCDetId>::const_iterator chIt;
00074     
00075     for(CSCRecHit2DCollection::const_iterator it2 = recHits->begin(); it2 != recHits->end(); it2++) {
00076         
00077         bool insert = true;
00078         for(chIt=chambers.begin(); chIt != chambers.end(); ++chIt) 
00079             if (((*it2).cscDetId().chamber() == (*chIt).chamber()) &&
00080                 ((*it2).cscDetId().station() == (*chIt).station()) &&
00081                 ((*it2).cscDetId().ring() == (*chIt).ring()) &&
00082                 ((*it2).cscDetId().endcap() == (*chIt).endcap()))
00083                 insert = false;
00084         
00085         if (insert)
00086             chambers.push_back((*it2).cscDetId().chamberId());
00087     }
00088 
00089     for(chIt=chambers.begin(); chIt != chambers.end(); ++chIt) {
00090 
00091         std::vector<const CSCRecHit2D*> cscRecHits;
00092         const CSCChamber* chamber = geom_->chamber(*chIt);
00093         
00094         CSCRangeMapAccessor acc;
00095         CSCRecHit2DCollection::range range = recHits->get(acc.cscChamber(*chIt));
00096         
00097         std::vector<int> hitPerLayer(6);
00098         for(CSCRecHit2DCollection::const_iterator rechit = range.first; rechit != range.second; rechit++) {
00099             
00100             hitPerLayer[(*rechit).cscDetId().layer()-1]++;
00101             cscRecHits.push_back(&(*rechit));
00102         }    
00103         
00104         LogDebug("CSC") << "found " << cscRecHits.size() << " rechit in this chamber.";
00105             
00106         // given the chamber select the right algo...
00107         std::vector<CSCSegment> segv = algoMap[chamber->specs()->chamberTypeName()]->run(chamber, cscRecHits);
00108 
00109         // Add the segments to master collection !!!
00110         LogDebug("CSC") << "Total number of segments found: " << segv.size() <<std::endl;
00111                 
00112         oc.put((*chIt), segv.begin(), segv.end());
00113     }
00114 }

void CSCSegmentBuilder::setGeometry ( const CSCGeometry geom  ) 

Cache pointer to geometry _for current event_.

Definition at line 116 of file CSCSegmentBuilder.cc.

References geom_.

Referenced by CSCSegmentProducer::produce().

00116                                                            {
00117         geom_ = geom;
00118 }


Member Data Documentation

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


The documentation for this class was generated from the following files:
Generated on Tue Jun 9 18:17:27 2009 for CMSSW by  doxygen 1.5.4