CMS 3D CMS Logo

GEMSegmentBuilder.cc
Go to the documentation of this file.
8 
11 
13 
14  // Algo name
15  algoName = ps.getParameter<std::string>("algo_name");
16 
17  edm::LogVerbatim("GEMSegmentBuilder")<< "GEMSegmentBuilder algorithm name: " << algoName;
18 
19  // SegAlgo parameter set
20  segAlgoPSet = ps.getParameter<edm::ParameterSet>("algo_pset");
21 
22  // Ask factory to build this algorithm, giving it appropriate ParameterSet
23  algo = std::unique_ptr<GEMSegmentAlgorithmBase>(GEMSegmentBuilderPluginFactory::get()->create(algoName, segAlgoPSet));
24 
25 }
27 
29 
30  edm::LogVerbatim("GEMSegmentBuilder")<< "[GEMSegmentBuilder::build] Total number of rechits in this event: " << recHits->size();
31 
32  // Let's define the ensemble of GEM devices having the same region, chambers number (phi)
33  // different eta partitions and different layers are allowed
34 
35  std::map<uint32_t, std::vector<const GEMRecHit*> > ensembleRH;
36 
37  // Loop on the GEM rechit and select the different GEM Ensemble
38  for(GEMRecHitCollection::const_iterator it2 = recHits->begin(); it2 != recHits->end(); ++it2) {
39  // GEM Ensemble is defined by assigning all the GEMDetIds of the same "superchamber"
40  // (i.e. region same, chamber same) to the DetId of the first layer
41 
42  // here a reference GEMDetId is created: named "id"
43  // - Ring 1 (no other rings available for GEM)
44  // - Layer 1 = reference layer (effective layermask)
45  // - Roll 0 = reference roll (effective rollmask)
46  // - Station == 1 (GE1/1) or == 2 (GE2/1)
47  // this reference id serves to link all GEMEtaPartitions
48  // and will also be used to determine the GEMSuperChamber
49  // to which the GEMSegment is assigned (done inside GEMSegAlgoXX)
50  GEMDetId id(it2->gemId().superChamberId());
51  // save current GEMRecHit in vector associated to the reference id
52  ensembleRH[id.rawId()].push_back(&(*it2));
53  }
54 
55  // Loop on the entire map <ref id, vector of GEMRecHits>
56  for(auto enIt=ensembleRH.begin(); enIt != ensembleRH.end(); ++enIt) {
57 
58  std::vector<const GEMRecHit*> gemRecHits;
59  std::map<uint32_t,const GEMEtaPartition* > ens;
60 
61  // all detIds have been assigned to the to chamber
62  const GEMSuperChamber* chamber = geom_->superChamber(enIt->first);
63  for(auto rechit = enIt->second.begin(); rechit != enIt->second.end(); ++rechit) {
64  gemRecHits.push_back(*rechit);
65  ens[(*rechit)->gemId()]=geom_->etaPartition((*rechit)->gemId());
66  }
67 
68  #ifdef EDM_ML_DEBUG // have lines below only compiled when in debug mode
69  LogTrace("GEMSegmentBuilder") << "[GEMSegmentBuilder::build] -----------------------------------------------------------------------------";
70  LogTrace("GEMSegmentBuilder") << "[GEMSegmentBuilder::build] found " << gemRecHits.size() << " rechits in GEM Super Chamber " << chamber->id()<<" ::";
71  for (auto rh=gemRecHits.begin(); rh!=gemRecHits.end(); ++rh){
72  auto gemid = (*rh)->gemId();
73  // auto rhr = gemGeom->etaPartition(gemid);
74  auto rhLP = (*rh)->localPosition();
75  // auto rhGP = rhr->toGlobal(rhLP);
76  // no sense to print local y because local y here is in the roll reference frame
77  // in the roll reference frame the local y of a rechit is always the middle of the roll, and hence equal to 0.0
78  LogTrace("GEMSegmentBuilder") << "[RecHit :: Loc x = "<<std::showpos<<std::setw(9)<<rhLP.x() /*<<" Loc y = "<<std::showpos<<std::setw(9)<<rhLP.y()*/
79  <<" BX = "<<(*rh)->BunchX()<<" -- "<<gemid.rawId()<<" = "<<gemid<<" ]";
80  }
81  #endif
82 
83 
84  GEMSegmentAlgorithmBase::GEMEnsemble ensemble(std::pair<const GEMSuperChamber*, std::map<uint32_t,const GEMEtaPartition*> >(chamber,ens));
85 
86  #ifdef EDM_ML_DEBUG // have lines below only compiled when in debug mode
87  LogTrace("GEMSegmentBuilder") << "[GEMSegmentBuilder::build] run the segment reconstruction algorithm now";
88  #endif
89 
90  // given the superchamber select the appropriate algo... and run it
91  std::vector<GEMSegment> segv = algo->run(ensemble, gemRecHits);
92  #ifdef EDM_ML_DEBUG // have lines below only compiled when in debug mode
93  LogTrace("GEMSegmentBuilder") << "[GEMSegmentBuilder::build] found " << segv.size() ;
94  #endif
95 
96  GEMDetId mid(enIt->first);
97 
98  #ifdef EDM_ML_DEBUG // have lines below only compiled when in debug mode
99  LogTrace("GEMSegmentBuilder") << "[GEMSegmentBuilder::build] found " << segv.size() << " segments in GEM Super Chamber " << mid;
100  LogTrace("GEMSegmentBuilder") << "[GEMSegmentBuilder::build] -----------------------------------------------------------------------------";
101  #endif
102 
103  // Add the segments to master collection
104  oc.put(mid, segv.begin(), segv.end());
105  }
106 }
107 
109  geom_ = geom;
110 }
T getParameter(std::string const &) const
const GEMGeometry * geom_
#define nullptr
void build(const GEMRecHitCollection *rechits, GEMSegmentCollection &oc)
std::pair< const GEMSuperChamber *, std::map< uint32_t, const GEMEtaPartition * > > GEMEnsemble
GEMSegmentBuilder(const edm::ParameterSet &)
const GEMEtaPartition * etaPartition(GEMDetId id) const
Return a GEMEtaPartition given its id.
Definition: GEMGeometry.cc:99
C::const_iterator const_iterator
constant access iterator type
Definition: RangeMap.h:43
#define LogTrace(id)
const GEMSuperChamber * superChamber(GEMDetId id) const
Definition: GEMGeometry.cc:91
~GEMSegmentBuilder()
Destructor.
GEMDetId id() const
Return the GEMDetId of this super chamber.
std::unique_ptr< GEMSegmentAlgorithmBase > algo
edm::ParameterSet segAlgoPSet
T get(const Candidate &c)
Definition: component.h:55
void setGeometry(const GEMGeometry *g)