CMS 3D CMS Logo

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