53 const std::map<uint32_t, const GEMEtaPartition*>& gemrollmap,
54 const std::vector<const CSCSegment*>& cscsegments,
55 const std::vector<const GEMRecHit*>& gemrechits) {
64 edm::LogVerbatim(
"GEMCSCSegAlgoRR") <<
"[GEMCSCSegAlgoRR::run] cached the csclayermap and the gemrollmap";
67 std::stringstream csclayermapss;
68 csclayermapss <<
"[GEMCSCSegAlgoRR::run] :: csclayermap :: elements [" << std::endl;
71 csclayermapss <<
"[CSC DetId " << mapIt->first <<
" =" <<
CSCDetId(mapIt->first) <<
", CSC Layer " << mapIt->second
72 <<
" =" << (mapIt->second)->
id() <<
"]," << std::endl;
74 csclayermapss <<
"]" << std::endl;
80 std::stringstream gemetapartmapss;
81 gemetapartmapss <<
"[GEMCSCSegAlgoRR::run] :: gemetapartmap :: elements [" << std::endl;
82 for (std::map<uint32_t, const GEMEtaPartition*>::const_iterator mapIt =
theGEMEtaParts_.begin();
85 gemetapartmapss <<
"[GEM DetId " << mapIt->first <<
" =" <<
GEMDetId(mapIt->first) <<
", GEM EtaPart "
86 << mapIt->second <<
"]," << std::endl;
88 gemetapartmapss <<
"]" << std::endl;
89 std::string gemetapartmapstr = gemetapartmapss.str();
93 std::vector<GEMCSCSegment> segmentvectorfinal;
94 std::vector<GEMCSCSegment> segmentvectorchamber;
95 std::vector<GEMCSCSegment> segmentvectorfromfit;
96 std::vector<const TrackingRecHit*> chainedRecHits;
111 for (std::vector<const CSCSegment*>::const_iterator cscSegIt = cscsegments.begin(); cscSegIt != cscsegments.end();
119 if (chainedRecHits.size() > (*cscSegIt)->specificRecHits().size()) {
120 segmentvectorfromfit = this->
buildSegments(*cscSegIt, chainedRecHits);
125 std::vector<const GEMRecHit*> gemRecHits_noGEMrh;
128 (*cscSegIt)->localPosition(),
129 (*cscSegIt)->localDirection(),
130 (*cscSegIt)->parametersError(),
131 (*cscSegIt)->chi2());
132 segmentvectorfromfit.push_back(
tmp);
135 segmentvectorchamber.insert(segmentvectorchamber.end(), segmentvectorfromfit.begin(), segmentvectorfromfit.end());
136 segmentvectorfromfit.clear();
140 segmentvectorfinal.insert(segmentvectorfinal.end(), segmentvectorchamber.begin(), segmentvectorchamber.end());
141 segmentvectorchamber.clear();
142 edm::LogVerbatim(
"GEMCSCSegAlgoRR") <<
"[GEMCSCSegAlgoRR::run] GEMCSC Segments fitted or wrapped, size of vector = "
143 << segmentvectorfinal.size();
144 return segmentvectorfinal;
155 const std::vector<const GEMRecHit*>& gemrechits) {
156 std::vector<const TrackingRecHit*> chainedRecHits;
168 for (
auto crh = cscrhs.begin(); crh != cscrhs.end(); crh++) {
169 chainedRecHits.push_back(crh->clone());
173 std::vector<const TrackingRecHit*>::const_iterator trhIt = chainedRecHits.begin();
175 if (trhIt == chainedRecHits.end()) {
177 <<
"[GEMCSCSegFit::chainHitsToSegm] CSC segment has zero rechits ... end function here";
178 return chainedRecHits;
184 <<
"[GEMCSCSegFit::chainHitsToSegm] CSC rechit ID was not found back in the CSCLayerMap ... end function here";
185 return chainedRecHits;
190 if (!gemrechits.empty()) {
191 float Dphi_min_l1 = 999;
192 float Dphi_min_l2 = 999;
193 float Dtheta_min_l1 = 999;
194 float Dtheta_min_l2 = 999;
196 std::vector<const GEMRecHit*>::const_iterator grhIt = gemrechits.begin();
202 for (grhIt = gemrechits.begin(); grhIt != gemrechits.end(); ++grhIt) {
209 auto rhLP_inSegmRef = cscChamber->
toLocal(rhGP);
212 float xe = 0.0, ye = 0.0, ze = 0.0;
213 if (segLD.z() != 0) {
214 xe = segLP.
x() + segLD.x() * rhLP_inSegmRef.z() / segLD.z();
215 ye = segLP.y() + segLD.y() * rhLP_inSegmRef.z() / segLD.z();
216 ze = rhLP_inSegmRef.z();
223 auto rhGP_fromSegmRef = cscChamber->
toGlobal(rhLP_inSegmRef);
224 float phi_rh = rhGP_fromSegmRef.
phi();
225 float theta_rh = rhGP_fromSegmRef.theta();
227 auto extrPoinGP_fromSegmRef = cscChamber->
toGlobal(extrPoint);
228 float phi_ext = extrPoinGP_fromSegmRef.
phi();
229 float theta_ext = extrPoinGP_fromSegmRef.theta();
233 if ((*grhIt)->gemId().layer() == 1) {
234 float Dphi_l1 = fabs(phi_ext - phi_rh);
235 float Dtheta_l1 = fabs(theta_ext - theta_rh);
236 if (Dphi_l1 <= Dphi_min_l1) {
237 Dphi_min_l1 = Dphi_l1;
238 Dtheta_min_l1 = Dtheta_l1;
239 gemrh_min_l1 = *grhIt;
244 if ((*grhIt)->gemId().layer() == 2) {
245 float Dphi_l2 = fabs(phi_ext - phi_rh);
246 float Dtheta_l2 = fabs(theta_ext - theta_rh);
247 if (Dphi_l2 <= Dphi_min_l2) {
248 Dphi_min_l2 = Dphi_l2;
249 Dtheta_min_l2 = Dtheta_l2;
250 gemrh_min_l2 = *grhIt;
261 if (phiRequirementOK_l1 && thetaRequirementOK_l1 && gemrh_min_l1 !=
nullptr) {
262 chainedRecHits.push_back(gemrh_min_l1->
clone());
266 if (phiRequirementOK_l2 && thetaRequirementOK_l2 && gemrh_min_l2 !=
nullptr) {
267 chainedRecHits.push_back(gemrh_min_l2->
clone());
271 return chainedRecHits;
280 const std::vector<const TrackingRecHit*>&
rechits) {
281 std::vector<GEMCSCSegment> gemcscsegmentvector;
282 std::vector<const GEMRecHit*> gemrechits;
286 return gemcscsegmentvector;
290 for (std::vector<const TrackingRecHit*>::const_iterator trhIt =
rechits.begin(); trhIt !=
rechits.end(); ++trhIt) {
292 gemrechits.push_back(((
const GEMRecHit*)*trhIt));
308 <<
"[GEMCSCSegAlgoRR::buildSegments] fit done, will now try to make GEMCSC Segment from CSC Segment in "
310 <<
" rechits and with chi2 = " << cscsegment->
chi2() <<
" and with " << gemrechits.size() <<
" GEM RecHits";
313 GEMCSCSegment tmp(cscsegment, gemrechits, protoIntercept, protoDirection, protoErrors, protoChi2);
315 edm::LogVerbatim(
"GEMCSCSegAlgoRR") <<
"[GEMCSCSegAlgoRR::buildSegments] GEMCSC Segment made";
316 gemcscsegmentvector.push_back(
tmp);
317 return gemcscsegmentvector;