23 const RPCRoll *aroll = dynamic_cast<const RPCRoll *>(whichdet3);
24 float locx = LocalP.
x(), locy = LocalP.
y();
27 float boundlength = rollbound.
length();
28 float boundwidth = rollbound.
width();
30 if (fabs(locx) < boundwidth / 2 && fabs(locy) < boundlength / 2 && locy > -boundlength / 2)
37 float boundlength = rollbound.
length();
38 float boundwidth = rollbound.
width();
41 float ylimit = ((boundlength) / (boundwidth / 2 - nminx / 2)) * fabs(locx) + boundlength / 2 -
42 ((boundlength) / (boundwidth / 2 - nminx / 2)) * (boundwidth / 2);
43 if (ylimit < -boundlength / 2)
44 ylimit = -boundlength / 2;
46 if (fabs(locx) < boundwidth / 2 && fabs(locy) < boundlength / 2 && locy > ylimit)
61 if (tracklabel.
label().find(
"cosmic") == 0)
63 else if (tracklabel.
label().find(
"globalCosmic") == 0)
72 auto _ThePoints = std::make_unique<RPCRecHitCollection>();
85 std::vector<uint32_t> rpcput;
88 for (TrackCollection::const_iterator
track = alltracks->begin();
track != alltracks->end();
track++) {
91 std::cout <<
"Building Trajectory from Track. " << std::endl;
93 std::vector<uint32_t> rpcrolls;
94 std::vector<uint32_t> rpcrolls2;
95 std::map<uint32_t, int> rpcNdtcsc;
96 std::map<uint32_t, int> rpcrollCounter;
98 float tInX =
track->innerPosition().X(), tInY =
track->innerPosition().Y(), tInZ =
track->innerPosition().Z();
99 float tOuX =
track->outerPosition().X(), tOuY =
track->outerPosition().Y(), tOuZ =
track->outerPosition().Z();
117 std::cout <<
"in (x,y,z): (" << tInX <<
", " << tInY <<
", " << tInZ <<
")" << std::endl;
119 std::cout <<
"out (x,y,z): (" << tOuX <<
", " << tOuY <<
", " << tOuZ <<
")" << std::endl;
122 std::cout <<
"1. Search expeted RPC roll detid !!" << std::endl;
124 if ((*hit)->isValid()) {
125 DetId id = (*hit)->geographicalId();
128 const GeomDet *geomDet = dtGeo->
idToDet((*hit)->geographicalId());
129 const DTLayer *dtlayer = dynamic_cast<const DTLayer *>(geomDet);
141 float dx = trajLP.
x() - trackLP.
x(),
dy = trajLP.
y() - trackLP.
y();
142 if (
dx > 10. &&
dy > 10.)
146 int dtW = dtid.
wheel(), dtS = dtid.sector(), dtT = dtid.station();
152 const std::set<RPCDetId> &rollsForThisDT = dtMap->
getRolls(theindex);
153 for (std::set<RPCDetId>::iterator iteraRoll = rollsForThisDT.begin(); iteraRoll != rollsForThisDT.end();
155 const RPCRoll *rollasociated = rpcGeo->
roll(*iteraRoll);
161 rpcrollCounter[rollasociated->
id().
rawId()]++;
163 std::vector<uint32_t>::iterator rpcroll;
164 for (rpcroll = rpcrolls.begin(); rpcroll < rpcrolls.end(); rpcroll++)
165 if (rollasociated->
id().
rawId() == *rpcroll)
168 rpcrolls.push_back(rollasociated->
id().
rawId());
172 << servId.name().c_str() << std::endl;
179 const GeomDet *geomDet = cscGeo->
idToDet((*hit)->geographicalId());
180 const CSCLayer *csclayer = dynamic_cast<const CSCLayer *>(geomDet);
192 if (upd2.
isValid() && cscid.station() != 4 && cscid.ring() != 1) {
195 float dx = trajLP.
x() - trackLP.
x(),
dy = trajLP.
y() - trackLP.
y();
196 if (
dx > 10. &&
dy > 10.)
199 int En = cscid.endcap(), St = cscid.station(), Ri = cscid.ring();
200 int rpcSegment = cscid.chamber();
207 const std::set<RPCDetId> &rollsForThisCSC = cscMap->
getRolls(theindex);
208 for (std::set<RPCDetId>::iterator iteraRoll = rollsForThisCSC.begin();
209 iteraRoll != rollsForThisCSC.end();
211 const RPCRoll *rollasociated = rpcGeo->
roll(*iteraRoll);
217 rpcrollCounter[rollasociated->
id().
rawId()]++;
219 std::vector<uint32_t>::iterator rpcroll;
220 for (rpcroll = rpcrolls.begin(); rpcroll < rpcrolls.end(); rpcroll++)
221 if (rollasociated->
id().
rawId() == *rpcroll)
224 rpcrolls.push_back(rollasociated->
id().
rawId());
228 << servId.name().c_str() << std::endl;
236 std::cout <<
"1\t The hit is not DT/CSC's. " << std::endl;
241 std::cout <<
"First step OK!!\n2. Search nearest DT/CSC sufrace!!" << std::endl;
242 std::vector<uint32_t>::iterator rpcroll;
243 for (rpcroll = rpcrolls.begin(); rpcroll < rpcrolls.end(); rpcroll++) {
249 if (rpcrollCounter[*rpcroll] < 3)
252 uint32_t dtcscid = 0;
259 if ((*hit)->isValid()) {
260 DetId id = (*hit)->geographicalId();
262 const GeomDet *geomDet = dtGeo->
idToDet((*hit)->geographicalId());
265 double dx = rGP.
x() - dtGP.
x(),
dy = rGP.
y() - dtGP.
y(),
dz = rGP.
z() - dtGP.
z();
269 int Se = dtid.
sector(), Wh = dtid.wheel(), St = dtid.station();
275 if (rEn == 0 && (rSe - Se) == 0 && (rWr - Wh) == 0 && (rSt - St) == 0 && distanceN <
distance) {
279 std::cout <<
"2\t DT " << dtcscid <<
" Wheel : " << Wh <<
" station : " << St <<
" sector : " << Se
283 const GeomDet *geomDet = cscGeo->
idToDet((*hit)->geographicalId());
287 double dx = rGP.
x() - cscGP.
x(),
dy = rGP.
y() - cscGP.
y(),
dz = rGP.
z() - cscGP.
z();
291 int En = cscid.
endcap(), Ri = cscid.ring(), St = cscid.station(), Ch = cscid.chamber();
297 if ((rEn - En) == 0 && (rSt - St) == 0 && (Ch - rCh) == 0 && rWr != 1 && rSt != 4 && distanceN <
distance) {
301 std::cout <<
"2\t CSC " << dtcscid <<
" region : " << En <<
" station : " << St <<
" Ring : " << Ri
302 <<
" chamber : " << Ch << std::endl;
308 rpcrolls2.push_back(*rpcroll);
309 rpcNdtcsc[*rpcroll] = dtcscid;
313 std::cout <<
"Second step OK!! \n3. Propagate to RPC from DT/CSC!!" << std::endl;
315 std::vector<uint32_t>::iterator rpcroll2;
316 for (rpcroll2 = rpcrolls2.begin(); rpcroll2 < rpcrolls2.end(); rpcroll2++) {
318 std::vector<uint32_t>::iterator rpcput_;
319 for (rpcput_ = rpcput.begin(); rpcput_ < rpcput.end(); rpcput_++)
320 if (*rpcroll2 == *rpcput_)
324 uint32_t dtcscid = rpcNdtcsc[*rpcroll2];
328 const DTLayer *dtlayer = dynamic_cast<const DTLayer *>(geomDet);
346 if (tInX > rpcGPX || tOuX < rpcGPX)
348 if (tInY > rpcGPY || tOuY < rpcGPY)
350 if (tInZ > rpcGPZ || tOuZ < rpcGPZ)
354 const RPCRoll *aroll = dynamic_cast<const RPCRoll *>(geomDet2);
356 dynamic_cast<const RectangularStripTopology *>(&(aroll->
topology()));
359 float rsize = fabs(
xmax.x() -
xmin.x());
366 if (locx < rsize * eyr && locy < stripl * eyr && locz < 1.) {
371 std::cout <<
"3\t Barrel Expected RPC " << servId.
name().c_str()
372 <<
" \tLocalposition X: " << locx <<
", Y: " << locy <<
" GlobalPosition(x,y,z) ("
373 << rpcGPX <<
", " << rpcGPY <<
", " << rpcGPZ <<
")" << std::endl;
374 RPCPointVector.
clear();
376 _ThePoints->put(*rpcroll2, RPCPointVector.
begin(), RPCPointVector.
end());
377 rpcput.push_back(*rpcroll2);
384 const CSCLayer *csclayer = dynamic_cast<const CSCLayer *>(geomDet4);
402 if (tInX > rpcGPX || tOuX < rpcGPX)
404 if (tInY > rpcGPY || tOuY < rpcGPY)
406 if (tInZ > rpcGPZ || tOuZ < rpcGPZ)
411 const RPCRoll *aroll = dynamic_cast<const RPCRoll *>(geomDet3);
413 dynamic_cast<const TrapezoidalStripTopology *>(&(aroll->
topology()));
416 float rsize = fabs(
xmax.x() -
xmin.x());
424 if (locx < rsize * eyr && locy < stripl * eyr && locz < 1.) {
428 std::cout <<
"3\t Forward Expected RPC " << servId.
name().c_str()
429 <<
" \tLocalposition X: " << locx <<
", Y: " << locy <<
" GlobalPosition(x,y,z) ("
430 << rpcGPX <<
", " << rpcGPY <<
", " << rpcGPZ <<
")" << std::endl;
431 RPCPointVector.
clear();
433 _ThePoints->put(*rpcroll2, RPCPointVector.
begin(), RPCPointVector.
end());
434 rpcput.push_back(*rpcroll2);
443 std::cout <<
"last steps OK!! " << std::endl;