test
CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
ME0SegmentBuilder.cc
Go to the documentation of this file.
8 
11 
13 
14  // Algo name
15  std::string algoName = ps.getParameter<std::string>("algo_name");
16 
17  LogDebug("ME0SegmentBuilder")<< "ME0SegmentBuilder algorithm name: " << algoName;
18 
19  // SegAlgo parameter set
20  edm::ParameterSet segAlgoPSet = ps.getParameter<edm::ParameterSet>("algo_pset");
21 
22  // Ask factory to build this algorithm, giving it appropriate ParameterSet
23  algo = ME0SegmentBuilderPluginFactory::get()->create(algoName, segAlgoPSet);
24 
25 }
27  delete algo;
28 }
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  std::vector<ME0RecHit* > pp = ensembleRH[id.rawId()];
49  pp.push_back(it2->clone());
50  ensembleRH[id.rawId()]=pp;
51  }
52 
53  for(auto enIt=ensembleRH.begin(); enIt != ensembleRH.end(); ++enIt) {
54 
55  std::vector<const ME0RecHit*> me0RecHits;
56  std::map<uint32_t,const ME0EtaPartition* > ens;
57 
58  // all detIds have been assigned to the according detId with layer 1
59  const ME0EtaPartition* firstlayer = geom_->etaPartition(enIt->first);
60  for(auto rechit = enIt->second.begin(); rechit != enIt->second.end(); ++rechit) {
61  me0RecHits.push_back(*rechit);
62  ens[(*rechit)->me0Id()]=geom_->etaPartition((*rechit)->me0Id());
63  }
64  ME0SegmentAlgorithm::ME0Ensemble ensemble(std::pair<const ME0EtaPartition*, std::map<uint32_t,const ME0EtaPartition*> >(firstlayer,ens));
65 
66  // LogDebug("ME0SegmentBuilder") << "found " << me0RecHits.size() << " rechits in chamber " << *enIt;
67 
68  // given the chamber select the appropriate algo... and run it
69  std::vector<ME0Segment> segv = algo->run(ensemble, me0RecHits);
70  ME0DetId mid(enIt->first);
71  LogDebug("ME0SegmentBuilder") << "found " << segv.size() << " segments in chamber " << mid;
72 
73  // Add the segments to master collection
74  oc.put(mid, segv.begin(), segv.end());
75  }
76 }
77 
79  geom_ = geom;
80 }
81 
#define LogDebug(id)
T getParameter(std::string const &) const
ME0SegmentAlgorithm * algo
virtual std::vector< ME0Segment > run(const ME0Ensemble &ensemble, const std::vector< const ME0RecHit * > &rechits)=0
tuple pp
Definition: createTree.py:15
std::pair< const ME0EtaPartition *, 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:61
void setGeometry(const ME0Geometry *g)
void build(const ME0RecHitCollection *rechits, ME0SegmentCollection &oc)
~ME0SegmentBuilder()
Destructor.
const ME0Geometry * geom_
T get(const Candidate &c)
Definition: component.h:55