28 float locx=LocalP.
x(), locy=LocalP.
y();
32 float boundlength = rollbound.
length();
33 float boundwidth = rollbound.
width();
35 if(fabs(locx) < boundwidth/2 && fabs(locy) < boundlength/2 && locy > -boundlength/2)
return true;
42 float boundlength = rollbound.
length();
43 float boundwidth = rollbound.
width();
46 float ylimit = ((boundlength)/(boundwidth/2 - nminx/2))*fabs(locx) + boundlength/2 - ((boundlength)/(boundwidth/2 - nminx/2))*(boundwidth/2);
47 if(ylimit < -boundlength/2 ) ylimit = -boundlength/2;
49 if(fabs(locx) < boundwidth/2 && fabs(locy) < boundlength/2 && locy > ylimit)
return true;
56 _ThePoints = std::make_unique<RPCRecHitCollection>();
77 std::vector<uint32_t> rpcput;
80 for (TrackCollection::const_iterator
track = alltracks->begin();
track !=alltracks->end();
track++)
83 if(debug)
std::cout <<
"Building Trajectory from Track. " << std::endl;
85 std::vector<uint32_t> rpcrolls;
86 std::vector<uint32_t> rpcrolls2;
87 std::map<uint32_t, int> rpcNdtcsc;
88 std::map<uint32_t, int> rpcrollCounter;
90 float tInX =
track->innerPosition().X(), tInY =
track->innerPosition().Y(), tInZ =
track->innerPosition().Z();
91 float tOuX =
track->outerPosition().X(), tOuY =
track->outerPosition().Y(), tOuZ =
track->outerPosition().Z();
92 if(tInX > tOuX) {
float temp=tOuX; tOuX=tInX; tInX=
temp; }
93 if(tInY > tOuY) {
float temp=tOuY; tOuY=tInY; tInY=
temp; }
94 if(tInZ > tOuZ) {
float temp=tOuZ; tOuZ=tInZ; tInZ=
temp; }
96 if(debug)
std::cout <<
"in (x,y,z): ("<< tInX <<
", "<< tInY <<
", "<< tInZ <<
")" << std::endl;
97 if(debug)
std::cout <<
"out (x,y,z): ("<< tOuX <<
", "<< tOuY <<
", "<< tOuZ <<
")" << std::endl;
99 if(debug)
std::cout <<
"1. Search expeted RPC roll detid !!" << std::endl;
102 if((*hit)->isValid())
104 DetId id = (*hit)->geographicalId();
108 const GeomDet *geomDet = dtGeo->
idToDet((*hit)->geographicalId());
110 if(dtlayer)
for(Trajectories::const_iterator trajectory = trajectories.begin(); trajectory != trajectories.end(); ++trajectory)
121 float dx = trajLP.
x()-trackLP.
x(),
dy=trajLP.
y()-trackLP.
y();
122 if( dx>10. &&
dy>10.)
continue;
125 int dtW=dtid.
wheel(), dtS=dtid.sector(), dtT=dtid.station();
129 std::set<RPCDetId> rollsForThisDT = dtMap->
getRolls(theindex);
130 for(std::set<RPCDetId>::iterator iteraRoll = rollsForThisDT.begin();iteraRoll != rollsForThisDT.end(); iteraRoll++)
132 const RPCRoll* rollasociated = rpcGeo->
roll(*iteraRoll);
137 rpcrollCounter[rollasociated->
id().
rawId()]++;
139 std::vector<uint32_t>::iterator rpcroll;
140 for( rpcroll=rpcrolls.begin() ; rpcroll < rpcrolls.end(); rpcroll++ )
141 if(rollasociated->
id().
rawId()== *rpcroll) check=
false;
144 rpcrolls.push_back(rollasociated->
id().
rawId());
146 if(debug)
std::cout <<
"1\t Barrel RPC roll" << rollasociated->
id().
rawId() <<
" "<< servId.name().c_str() <<std::endl;
155 const GeomDet *geomDet = cscGeo->
idToDet((*hit)->geographicalId());
159 if(csclayer)
for(Trajectories::const_iterator trajectory = trajectories.begin(); trajectory != trajectories.end(); ++trajectory)
167 if(upd2.
isValid() && cscid.station()!=4 && cscid.ring()!=1 )
171 float dx = trajLP.
x()-trackLP.
x(),
dy=trajLP.
y()-trackLP.
y();
172 if( dx>10. &&
dy>10.)
continue;
174 int En = cscid.endcap(), St = cscid.station(), Ri = cscid.ring();
175 int rpcSegment = cscid.chamber();
180 std::set<RPCDetId> rollsForThisCSC = cscMap->
getRolls(theindex);
181 for (std::set<RPCDetId>::iterator iteraRoll = rollsForThisCSC.begin();iteraRoll != rollsForThisCSC.end(); iteraRoll++)
183 const RPCRoll* rollasociated = rpcGeo->
roll(*iteraRoll);
188 rpcrollCounter[rollasociated->
id().
rawId()]++;
190 std::vector<uint32_t>::iterator rpcroll;
191 for( rpcroll=rpcrolls.begin() ; rpcroll < rpcrolls.end(); rpcroll++ )
192 if(rollasociated->
id().
rawId()==*rpcroll) check=
false;
195 rpcrolls.push_back(rollasociated->
id().
rawId());
197 if(debug)
std::cout <<
"1\t Forward RPC roll" << rollasociated->
id().
rawId() <<
" "<< servId.name().c_str() <<std::endl;
203 }
else {
if(debug)
std::cout <<
"1\t The hit is not DT/CSC's. " << std::endl;}
206 if(debug)
std::cout <<
"First step OK!!\n2. Search nearest DT/CSC sufrace!!" << std::endl;
207 std::vector<uint32_t>::iterator rpcroll;
208 for( rpcroll=rpcrolls.begin() ; rpcroll < rpcrolls.end(); rpcroll++ )
215 if(rpcrollCounter[*rpcroll]<3) continue ;
224 if((*hit)->isValid())
226 DetId id = (*hit)->geographicalId();
229 const GeomDet *geomDet = dtGeo->
idToDet((*hit)->geographicalId());
232 double dx = rGP.
x()-dtGP.
x(),
dy = rGP.
y()-dtGP.
y(),
dz = rGP.
z()-dtGP.
z();
236 int Se = dtid.
sector(), Wh = dtid.wheel(), St = dtid.station();
240 if( rEn==0&& (rSe-Se)==0 && (rWr-Wh) ==0 && (rSt-St)==0 && distanceN < distance)
243 distance = distanceN;
244 if(debug)
std::cout <<
"2\t DT "<< dtcscid <<
" Wheel : " << Wh <<
" station : " << St <<
" sector : " << Se << std::endl;
249 const GeomDet *geomDet = cscGeo->
idToDet((*hit)->geographicalId());
252 double dx = rGP.
x()-cscGP.
x(),
dy = rGP.
y()-cscGP.
y(),
dz = rGP.
z()-cscGP.
z();
256 int En =cscid.
endcap(), Ri=cscid.ring(), St=cscid.station(), Ch=cscid.chamber();
260 if((rEn-En)==0 && (rSt-St)==0 && (Ch-rCh) ==0 && rWr!=1 && rSt!=4 && distanceN < distance)
263 distance = distanceN;
264 if(debug)
std::cout <<
"2\t CSC " <<dtcscid <<
" region : " << En <<
" station : " << St <<
" Ring : " << Ri <<
" chamber : " << Ch <<std::endl;
269 if(dtcscid != 0 && distance < MaxD)
271 rpcrolls2.push_back(*rpcroll);
272 rpcNdtcsc[*rpcroll] = dtcscid;
275 if(debug)
std::cout <<
"Second step OK!! \n3. Propagate to RPC from DT/CSC!!" << std::endl;
277 std::vector<uint32_t>::iterator rpcroll2;
278 for( rpcroll2=rpcrolls2.begin() ; rpcroll2 < rpcrolls2.end(); rpcroll2++ )
281 std::vector<uint32_t>::iterator rpcput_;
282 for( rpcput_=rpcput.begin() ; rpcput_ < rpcput.end(); rpcput_++ )
283 if(*rpcroll2==*rpcput_) check =
false;
287 uint32_t dtcscid = rpcNdtcsc[*rpcroll2];
294 if(dtlayer)
for(Trajectories::const_iterator trajectory = trajectories.begin(); trajectory != trajectories.end(); ++trajectory)
310 if(tInX > rpcGPX || tOuX < rpcGPX )
continue;
311 if(tInY > rpcGPY || tOuY < rpcGPY )
continue;
312 if(tInZ > rpcGPZ || tOuZ < rpcGPZ )
continue;
319 float rsize = fabs( xmax.
x()-xmin.
x() );
325 if( locx < rsize*eyr && locy < stripl*eyr && locz < 1. )
330 if(debug)
std::cout <<
"3\t Barrel Expected RPC " << servId.
name().c_str() <<
331 " \tLocalposition X: " << locx <<
", Y: "<< locy <<
" GlobalPosition(x,y,z) (" << rpcGPX <<
", "<< rpcGPY <<
", " << rpcGPZ <<
")"<< std::endl;
335 rpcput.push_back(*rpcroll2);
346 if(csclayer)
for(Trajectories::const_iterator trajectory = trajectories.begin(); trajectory != trajectories.end(); ++trajectory)
362 if(tInX > rpcGPX || tOuX < rpcGPX )
continue;
363 if(tInY > rpcGPY || tOuY < rpcGPY )
continue;
364 if(tInZ > rpcGPZ || tOuZ < rpcGPZ )
continue;
372 float rsize = fabs( xmax.
x()-xmin.
x() );
379 if( locx < rsize*eyr && locy < stripl*eyr && locz < 1. )
383 if(debug)
std::cout <<
"3\t Forward Expected RPC " << servId.
name().c_str() <<
384 " \tLocalposition X: " << locx <<
", Y: "<< locy <<
" GlobalPosition(x,y,z) (" << rpcGPX <<
", "<< rpcGPY <<
", " << rpcGPZ <<
")"<< std::endl;
388 rpcput.push_back(*rpcroll2);
397 if(debug)
std::cout <<
"last steps OK!! " << std::endl;
std::vector< Trajectory > Trajectories
GlobalPoint toGlobal(const Point2DBase< Scalar, LocalTag > lp) const
edm::ESHandle< Propagator > thePropagator
virtual float length() const =0
const Topology & topology() const
Point3DBase< Scalar, LocalTag > LocalPoint
virtual float stripLength() const
edm::OwnVector< RPCRecHit > RPCPointVector
virtual const GeomDet * idToDet(DetId) const override
LocalPoint localPosition() const
GlobalPoint toGlobal(const Local2DPoint &lp) const
Conversion to the global R.F. from the R.F. of the GeomDet.
std::vector< Track > TrackCollection
collection of Tracks
GlobalPoint globalPosition() const
const Bounds & bounds() const
std::set< RPCDetId > const & getRolls(CSCStationIndex index) const
TracktoRPC(reco::TrackCollection const *alltracks, edm::EventSetup const &iSetup, bool debug, const edm::ParameterSet &iConfig, const edm::InputTag &tracklabel)
const Plane & surface() const
The nominal surface of the GeomDet.
std::set< RPCDetId > const & getRolls(DTStationIndex index) const
uint32_t rawId() const
get the raw id
TrackTransformerBase * theTrackTransformer
virtual float width() const =0
std::unique_ptr< RPCRecHitCollection > _ThePoints
virtual std::string name()
bool ValidRPCSurface(RPCDetId rpcid, LocalPoint LocalP, const edm::EventSetup &iSetup)
DetId geographicalId() const
The label of this GeomDet.
TrajectoryStateOnSurface propagate(STA const &state, SUR const &surface) const
virtual LocalPoint localPosition(float strip) const
int sector() const
Sector id: the group of chambers at same phi (and increasing r)
virtual const GeomDet * idToDet(DetId) const override
virtual const GeomDet * idToDet(DetId) const override
virtual LocalPoint localPosition(float strip) const
int wheel() const
Return the wheel number.
virtual float stripLength() const
det heigth (strip length in the middle)
const RPCRoll * roll(RPCDetId id) const
Return a roll given its id.
TrackingRecHitCollection::base::const_iterator trackingRecHit_iterator
iterator over a vector of reference to TrackingRecHit in the same collection
int region() const
Region id: 0 for Barrel, +/-1 For +/- Endcap.