test
CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
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
< ME0SegmentAlgorithmBase
algo
 
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, reco::get(), edm::ParameterSet::getParameter(), LogDebug, and AlCaHLTBitMon_QueryRunRegistry::string.

13  : geom_(0) {
14 
15  // Algo name
16  std::string algoName = ps.getParameter<std::string>("algo_name");
17 
18  LogDebug("ME0SegmentBuilder")<< "ME0SegmentBuilder algorithm name: " << algoName;
19 
20  // SegAlgo parameter set
21  edm::ParameterSet segAlgoPSet = ps.getParameter<edm::ParameterSet>("algo_pset");
22 
23  // Ask factory to build this algorithm, giving it appropriate ParameterSet
24  algo = std::unique_ptr<ME0SegmentAlgorithmBase>(ME0SegmentBuilderPluginFactory::get()->create(algoName, segAlgoPSet));
25 
26 }
#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 28 of file ME0SegmentBuilder.cc.

28 {}

Member Function Documentation

void ME0SegmentBuilder::build ( const ME0RecHitCollection rechits,
ME0SegmentCollection oc 
)

Find rechits in each ensemble of 6 ME0 layers, build ME0Segment's , and fill into output collection.

Definition at line 30 of file ME0SegmentBuilder.cc.

References algo, ME0Geometry::chamber(), ME0DetId::chamberId(), ME0Geometry::etaPartition(), geom_, LogDebug, me0RecHits_cfi::me0RecHits, and DetId::rawId().

30  {
31 
32  LogDebug("ME0SegmentBuilder")<< "Total number of rechits in this event: " << recHits->size();
33 
34  // Let's define the ensemble of ME0 devices having the same region, chambers number (phi), and eta partition
35  // and layer run from 1 to number of layer. This is not the definition of one chamber... and indeed segments
36  // could in principle run in different way... The concept of the DetLayer would be more appropriate...
37 
38  std::map<uint32_t, std::vector<ME0RecHit*> > ensembleRH;
39 
40  // Loop on the ME0 rechit and select the different ME0 Ensemble
41  for(ME0RecHitCollection::const_iterator it2 = recHits->begin(); it2 != recHits->end(); ++it2) {
42  // ME0 Ensemble is defined by assigning all the ME0DetIds of the same "superchamber"
43  // (i.e. region same, chamber same) to the DetId of the first layer
44  // At this point there is only one roll, so nothing to be worried about ...
45  // [At a later stage one will have to mask also the rolls
46  // if one wants to recover segments that are at the border of a roll]
47  ME0DetId id(it2->me0Id().region(),1,it2->me0Id().chamber(),it2->me0Id().roll());
48  // save current ME0RecHit in vector associated to the reference id
49  ensembleRH[id.rawId()].push_back(it2->clone());
50  }
51 
52  std::map<uint32_t, std::vector<ME0Segment> > ensembleSeg; // collect here all segments from the same chamber
53 
54  for(auto enIt=ensembleRH.begin(); enIt != ensembleRH.end(); ++enIt) {
55 
56  std::vector<const ME0RecHit*> me0RecHits;
57  std::map<uint32_t,const ME0EtaPartition* > ens;
58 
59  // all detIds have been assigned to the to chamber
60  const ME0Chamber* chamber = geom_->chamber(enIt->first);
61  for(auto rechit = enIt->second.begin(); rechit != enIt->second.end(); ++rechit) {
62  me0RecHits.push_back(*rechit);
63  ens[(*rechit)->me0Id()]=geom_->etaPartition((*rechit)->me0Id());
64  }
65  ME0SegmentAlgorithmBase::ME0Ensemble ensemble(std::pair<const ME0Chamber*, std::map<uint32_t,const ME0EtaPartition*> >(chamber,ens));
66 
67  ME0DetId mid(enIt->first);
68  #ifdef EDM_ML_DEBUG
69  LogDebug("ME0SegmentBuilder") << "found " << me0RecHits.size() << " rechits in etapart " << mid;
70  #endif
71 
72  // given the chamber select the appropriate algo... and run it
73  std::vector<ME0Segment> segv = algo->run(ensemble, me0RecHits);
74 
75  #ifdef EDM_ML_DEBUG
76  LogDebug("ME0SegmentBuilder") << "found " << segv.size() << " segments in etapart " << mid;
77  #endif
78 
79  // Add the segments to master collection
80  // oc.put(mid, segv.begin(), segv.end());
81 
82  // Add the segments to the chamber segment collection
83  // segment is defined from first partition of first layer
84  ME0DetId midch = mid.chamberId();
85  ensembleSeg[midch.rawId()].insert(ensembleSeg[midch.rawId()].end(), segv.begin(), segv.end());
86  }
87 
88  for(auto segIt=ensembleSeg.begin(); segIt != ensembleSeg.end(); ++segIt) {
89  // Add the segments to master collection
90  ME0DetId midch(segIt->first);
91  oc.put(midch, segIt->second.begin(), segIt->second.end());
92  }
93 }
#define LogDebug(id)
ME0DetId chamberId() const
Return the corresponding ChamberId (mask layers)
Definition: ME0DetId.h:67
std::pair< const ME0Chamber *, std::map< uint32_t, const ME0EtaPartition * > > ME0Ensemble
const ME0EtaPartition * etaPartition(ME0DetId id) const
Return a etaPartition given its id.
Definition: ME0Geometry.cc:64
uint32_t rawId() const
get the raw id
Definition: DetId.h:43
const ME0Chamber * chamber(ME0DetId id) const
Return a chamber given its id.
Definition: ME0Geometry.cc:73
std::unique_ptr< ME0SegmentAlgorithmBase > algo
const ME0Geometry * geom_
void ME0SegmentBuilder::setGeometry ( const ME0Geometry g)

Cache pointer to geometry for current event

Definition at line 95 of file ME0SegmentBuilder.cc.

References relativeConstraints::geom, and geom_.

95  {
96  geom_ = geom;
97 }
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().