CMS 3D CMS Logo

ME0SegmentBuilder.cc
Go to the documentation of this file.
9 
12 
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 }
27 
29 
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 }
94 
96  geom_ = geom;
97 }
98 
#define LogDebug(id)
T getParameter(std::string const &) const
ME0DetId chamberId() const
Return the corresponding ChamberId (mask layers)
Definition: ME0DetId.h:67
std::pair< const ME0Chamber *, std::map< uint32_t, const ME0EtaPartition * > > ME0Ensemble
ME0SegmentBuilder(const edm::ParameterSet &)
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
void setGeometry(const ME0Geometry *g)
const ME0Chamber * chamber(ME0DetId id) const
Return a chamber given its id.
Definition: ME0Geometry.cc:73
void build(const ME0RecHitCollection *rechits, ME0SegmentCollection &oc)
~ME0SegmentBuilder()
Destructor.
std::unique_ptr< ME0SegmentAlgorithmBase > algo
const ME0Geometry * geom_
T get(const Candidate &c)
Definition: component.h:55