26 const GeomDet *whichdet3 = rpcGeo->idToDet(rpcid.
rawId());
28 float locx=LocalP.
x(), locy=LocalP.
y();
31 const Bounds &rollbound = rpcGeo->idToDet((rpcid))->surface().bounds();
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;
41 const Bounds &rollbound = rpcGeo->idToDet((rpcid))->surface().bounds();
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;
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();
126 if(dtS==13) dtS=4;
if(dtS==14) dtS=10;
128 std::set<RPCDetId> rollsForThisDT = dtMap->getRolls(theindex);
129 for(std::set<RPCDetId>::iterator iteraRoll = rollsForThisDT.begin();iteraRoll != rollsForThisDT.end(); iteraRoll++)
131 const RPCRoll* rollasociated = rpcGeo->roll(*iteraRoll);
136 rpcrollCounter[rollasociated->
id().
rawId()]++;
138 std::vector<uint32_t>::iterator rpcroll;
139 for( rpcroll=rpcrolls.begin() ; rpcroll < rpcrolls.end(); rpcroll++ )
140 if(rollasociated->
id().
rawId()== *rpcroll) check=
false;
143 rpcrolls.push_back(rollasociated->
id().
rawId());
145 if(debug)
std::cout <<
"1\t Barrel RPC roll" << rollasociated->
id().
rawId() <<
" "<< servId.name().c_str() <<std::endl;
154 const GeomDet *geomDet = cscGeo->idToDet((*hit)->geographicalId());
158 if(csclayer)
for(Trajectories::const_iterator trajectory = trajectories.begin(); trajectory != trajectories.end(); ++trajectory)
166 if(upd2.
isValid() && cscid.station()!=4 && cscid.ring()!=1 )
170 float dx = trajLP.
x()-trackLP.
x(), dy=trajLP.
y()-trackLP.
y();
171 if( dx>10. && dy>10.)
continue;
173 int En = cscid.endcap(), St = cscid.station(), Ri = cscid.ring();
174 int rpcSegment = cscid.chamber();
175 if(En==2) En= -1;
if(Ri==4) Ri =1;
178 std::set<RPCDetId> rollsForThisCSC = cscMap->getRolls(theindex);
179 for (std::set<RPCDetId>::iterator iteraRoll = rollsForThisCSC.begin();iteraRoll != rollsForThisCSC.end(); iteraRoll++)
181 const RPCRoll* rollasociated = rpcGeo->roll(*iteraRoll);
186 rpcrollCounter[rollasociated->
id().
rawId()]++;
188 std::vector<uint32_t>::iterator rpcroll;
189 for( rpcroll=rpcrolls.begin() ; rpcroll < rpcrolls.end(); rpcroll++ )
190 if(rollasociated->
id().
rawId()==*rpcroll) check=
false;
193 rpcrolls.push_back(rollasociated->
id().
rawId());
195 if(debug)
std::cout <<
"1\t Forward RPC roll" << rollasociated->
id().
rawId() <<
" "<< servId.name().c_str() <<std::endl;
201 }
else {
if(debug)
std::cout <<
"1\t The hit is not DT/CSC's. " << std::endl;}
204 if(debug)
std::cout <<
"First step OK!!\n2. Search nearest DT/CSC sufrace!!" << std::endl;
205 std::vector<uint32_t>::iterator rpcroll;
206 for( rpcroll=rpcrolls.begin() ; rpcroll < rpcrolls.end(); rpcroll++ )
213 if(rpcrollCounter[*rpcroll]<3) continue ;
222 if((*hit)->isValid())
224 DetId id = (*hit)->geographicalId();
227 const GeomDet *geomDet = dtGeo->idToDet((*hit)->geographicalId());
229 const GlobalPoint &dtGP = dtGeo->idToDet((*hit)->geographicalId())->surface().toGlobal(
LocalPoint(0,0,0));
230 double dx = rGP.
x()-dtGP.
x(), dy = rGP.
y()-dtGP.
y(), dz = rGP.
z()-dtGP.
z();
231 double distanceN =
sqrt(dx*dx+dy*dy+dz*dz);
234 int Se = dtid.
sector(), Wh = dtid.wheel(), St = dtid.station();
235 if(Se == 13) Se=4;
if(Se ==14) Se=10;
237 if( rEn==0&& (rSe-Se)==0 && (rWr-Wh) ==0 && (rSt-St)==0 && distanceN < distance)
240 distance = distanceN;
241 if(debug)
std::cout <<
"2\t DT "<< dtcscid <<
" Wheel : " << Wh <<
" station : " << St <<
" sector : " << Se << std::endl;
246 const GeomDet *geomDet = cscGeo->idToDet((*hit)->geographicalId());
248 const GlobalPoint &cscGP = cscGeo->idToDet((*hit)->geographicalId())->surface().toGlobal(
LocalPoint(0,0,0));
249 double dx = rGP.
x()-cscGP.
x(), dy = rGP.
y()-cscGP.
y(), dz = rGP.
z()-cscGP.
z();
250 double distanceN =
sqrt(dx*dx+dy*dy+dz*dz);
253 int En =cscid.
endcap(), Ri=cscid.ring(), St=cscid.station(), Ch=cscid.chamber();
254 if(En==2) En=-1;
if(Ri==4) Ri=1;
256 if((rEn-En)==0 && (rSt-St)==0 && (Ch-rCh) ==0 && rWr!=1 && rSt!=4 && distanceN < distance)
259 distance = distanceN;
260 if(debug)
std::cout <<
"2\t CSC " <<dtcscid <<
" region : " << En <<
" station : " << St <<
" Ring : " << Ri <<
" chamber : " << Ch <<std::endl;
265 if(dtcscid != 0 && distance < MaxD)
267 rpcrolls2.push_back(*rpcroll);
268 rpcNdtcsc[*rpcroll] = dtcscid;
271 if(debug)
std::cout <<
"Second step OK!! \n3. Propagate to RPC from DT/CSC!!" << std::endl;
273 std::vector<uint32_t>::iterator rpcroll2;
274 for( rpcroll2=rpcrolls2.begin() ; rpcroll2 < rpcrolls2.end(); rpcroll2++ )
277 std::vector<uint32_t>::iterator rpcput_;
278 for( rpcput_=rpcput.begin() ; rpcput_ < rpcput.end(); rpcput_++ )
279 if(*rpcroll2==*rpcput_) check =
false;
283 uint32_t dtcscid = rpcNdtcsc[*rpcroll2];
287 const GeomDet *geomDet = dtGeo->idToDet(dtcscid);
290 if(dtlayer)
for(Trajectories::const_iterator trajectory = trajectories.begin(); trajectory != trajectories.end(); ++trajectory)
306 if(tInX > rpcGPX || tOuX < rpcGPX )
continue;
307 if(tInY > rpcGPY || tOuY < rpcGPY )
continue;
308 if(tInZ > rpcGPZ || tOuZ < rpcGPZ )
continue;
310 const GeomDet *geomDet2 = rpcGeo->idToDet(*rpcroll2);
315 float rsize = fabs( xmax.
x()-xmin.
x() );
321 if( locx < rsize*eyr && locy < stripl*eyr && locz < 1. )
326 if(debug)
std::cout <<
"3\t Barrel Expected RPC " << servId.
name().c_str() <<
327 " \tLocalposition X: " << locx <<
", Y: "<< locy <<
" GlobalPosition(x,y,z) (" << rpcGPX <<
", "<< rpcGPY <<
", " << rpcGPZ <<
")"<< std::endl;
331 rpcput.push_back(*rpcroll2);
339 const GeomDet *geomDet4 = cscGeo->idToDet(dtcscid);
342 if(csclayer)
for(Trajectories::const_iterator trajectory = trajectories.begin(); trajectory != trajectories.end(); ++trajectory)
358 if(tInX > rpcGPX || tOuX < rpcGPX )
continue;
359 if(tInY > rpcGPY || tOuY < rpcGPY )
continue;
360 if(tInZ > rpcGPZ || tOuZ < rpcGPZ )
continue;
363 const GeomDet *geomDet3 = rpcGeo->idToDet(*rpcroll2);
368 float rsize = fabs( xmax.
x()-xmin.
x() );
375 if( locx < rsize*eyr && locy < stripl*eyr && locz < 1. )
379 if(debug)
std::cout <<
"3\t Forward Expected RPC " << servId.
name().c_str() <<
380 " \tLocalposition X: " << locx <<
", Y: "<< locy <<
" GlobalPosition(x,y,z) (" << rpcGPX <<
", "<< rpcGPY <<
", " << rpcGPZ <<
")"<< std::endl;
384 rpcput.push_back(*rpcroll2);
393 if(debug)
std::cout <<
"last steps OK!! " << std::endl;
std::vector< Trajectory > Trajectories
edm::ESHandle< Propagator > thePropagator
const Topology & topology() const
virtual float length() const =0
virtual float stripLength() const
edm::OwnVector< RPCRecHit > RPCPointVector
LocalPoint localPosition() const
std::vector< Track > TrackCollection
collection of Tracks
GlobalPoint globalPosition() 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.
uint32_t rawId() const
get the raw id
TrackTransformerBase * theTrackTransformer
std::unique_ptr< RPCRecHitCollection > _ThePoints
virtual std::string name()
bool ValidRPCSurface(RPCDetId rpcid, LocalPoint LocalP, const edm::EventSetup &iSetup)
bool check(const std::string &)
DetId geographicalId() const
The label of this GeomDet.
edm::RangeMap< RPCDetId, edm::OwnVector< RPCRecHit, edm::ClonePolicy< RPCRecHit > >, edm::ClonePolicy< RPCRecHit > > RPCRecHitCollection
virtual LocalPoint localPosition(float strip) const
int sector() const
Sector id: the group of chambers at same phi (and increasing r)
virtual LocalPoint localPosition(float strip) const
int wheel() const
Return the wheel number.
virtual float width() const =0
virtual float stripLength() const
det heigth (strip length in the middle)
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.