170 std::vector<uint32_t> rpcput;
173 for (TrackCollection::const_iterator track = alltracks->begin(); track !=alltracks->end(); track++)
176 if(
debug)
std::cout <<
"Building Trajectory from Track. " << std::endl;
178 std::vector<uint32_t> rpcrolls;
179 std::vector<uint32_t> rpcrolls2;
180 std::map<uint32_t, int> rpcNdtcsc;
181 std::map<uint32_t, int> rpcrollCounter;
183 float tInX = track->innerPosition().X(), tInY = track->innerPosition().Y(), tInZ = track->innerPosition().Z();
184 float tOuX = track->outerPosition().X(), tOuY = track->outerPosition().Y(), tOuZ = track->outerPosition().Z();
185 if(tInX > tOuX) {
float temp=tOuX; tOuX=tInX; tInX=
temp; }
186 if(tInY > tOuY) {
float temp=tOuY; tOuY=tInY; tInY=
temp; }
187 if(tInZ > tOuZ) {
float temp=tOuZ; tOuZ=tInZ; tInZ=
temp; }
189 if(
debug)
std::cout <<
"in (x,y,z): ("<< tInX <<
", "<< tInY <<
", "<< tInZ <<
")" << std::endl;
190 if(
debug)
std::cout <<
"out (x,y,z): ("<< tOuX <<
", "<< tOuY <<
", "<< tOuZ <<
")" << std::endl;
192 if(
debug)
std::cout <<
"1. Search expeted RPC roll detid !!" << std::endl;
195 if((*hit)->isValid())
197 DetId id = (*hit)->geographicalId();
201 const GeomDet *geomDet = dtGeo->idToDet((*hit)->geographicalId());
203 if(dtlayer)
for(Trajectories::const_iterator trajectory = trajectories.begin(); trajectory != trajectories.end(); ++trajectory)
214 float dx = trajLP.
x()-trackLP.
x(), dy=trajLP.
y()-trackLP.
y();
215 if( dx>10. && dy>10.)
continue;
218 int dtW=dtid.
wheel(), dtS=dtid.sector(), dtT=dtid.station();
219 if(dtS==13) dtS=4;
if(dtS==14) dtS=10;
223 for(std::set<RPCDetId>::iterator iteraRoll = rollsForThisDT.begin();iteraRoll != rollsForThisDT.end(); iteraRoll++)
225 const RPCRoll* rollasociated = rpcGeo->roll(*iteraRoll);
230 rpcrollCounter[rollasociated->
id().
rawId()]++;
232 std::vector<uint32_t>::iterator rpcroll;
233 for( rpcroll=rpcrolls.begin() ; rpcroll < rpcrolls.end(); rpcroll++ )
234 if(rollasociated->
id().
rawId()== *rpcroll) check=
false;
237 rpcrolls.push_back(rollasociated->
id().
rawId());
239 if(
debug)
std::cout <<
"1\t Barrel RPC roll" << rollasociated->
id().
rawId() <<
" "<< servId.name().c_str() <<std::endl;
248 const GeomDet *geomDet = cscGeo->idToDet((*hit)->geographicalId());
252 if(csclayer)
for(Trajectories::const_iterator trajectory = trajectories.begin(); trajectory != trajectories.end(); ++trajectory)
260 if(upd2.
isValid() && cscid.station()!=4 && cscid.ring()!=1 )
264 float dx = trajLP.
x()-trackLP.
x(), dy=trajLP.
y()-trackLP.
y();
265 if( dx>10. && dy>10.)
continue;
268 int En = cscid.endcap(), St = cscid.station(), Ri = cscid.ring();
269 int rpcSegment = cscid.chamber();
270 if(En==2) En= -1;
if(Ri==4) Ri =1;
273 std::set<RPCDetId> rollsForThisCSC = TheObjectCSC->
GetInstance(iSetup)->
GetRolls(theindex);
274 for (std::set<RPCDetId>::iterator iteraRoll = rollsForThisCSC.begin();iteraRoll != rollsForThisCSC.end(); iteraRoll++)
276 const RPCRoll* rollasociated = rpcGeo->roll(*iteraRoll);
281 rpcrollCounter[rollasociated->
id().
rawId()]++;
283 std::vector<uint32_t>::iterator rpcroll;
284 for( rpcroll=rpcrolls.begin() ; rpcroll < rpcrolls.end(); rpcroll++ )
285 if(rollasociated->
id().
rawId()==*rpcroll) check=
false;
288 rpcrolls.push_back(rollasociated->
id().
rawId());
290 if(
debug)
std::cout <<
"1\t Forward RPC roll" << rollasociated->
id().
rawId() <<
" "<< servId.name().c_str() <<std::endl;
296 }
else {
if(
debug)
std::cout <<
"1\t The hit is not DT/CSC's. " << std::endl;}
299 if(
debug)
std::cout <<
"First step OK!!\n2. Search nearest DT/CSC sufrace!!" << std::endl;
300 std::vector<uint32_t>::iterator rpcroll;
301 for( rpcroll=rpcrolls.begin() ; rpcroll < rpcrolls.end(); rpcroll++ )
306 int rEn=rpcid.region(), rSe=rpcid.sector(), rWr=rpcid.ring(), rSt=rpcid.station(), rCh=servId.segment();
308 if(rpcrollCounter[*rpcroll]<3) continue ;
310 uint32_t dtcscid=0;
double distance=
MaxD;
317 if((*hit)->isValid())
319 DetId id = (*hit)->geographicalId();
322 const GeomDet *geomDet = dtGeo->idToDet((*hit)->geographicalId());
324 const GlobalPoint &dtGP = dtGeo->idToDet((*hit)->geographicalId())->surface().toGlobal(
LocalPoint(0,0,0));
325 double dx = rGP.
x()-dtGP.
x(), dy = rGP.
y()-dtGP.
y(), dz = rGP.
z()-dtGP.
z();
326 double distanceN =
sqrt(dx*dx+dy*dy+dz*dz);
329 int Se = dtid.
sector(), Wh = dtid.wheel(), St = dtid.station();
330 if(Se == 13) Se=4;
if(Se ==14) Se=10;
332 if( rEn==0&& (rSe-Se)==0 && (rWr-Wh) ==0 && (rSt-St)==0 && distanceN < distance)
335 distance = distanceN;
336 if(
debug)
std::cout <<
"2\t DT "<< dtcscid <<
" Wheel : " << Wh <<
" station : " << St <<
" sector : " << Se << std::endl;
341 const GeomDet *geomDet = cscGeo->idToDet((*hit)->geographicalId());
343 const GlobalPoint &cscGP = cscGeo->idToDet((*hit)->geographicalId())->surface().toGlobal(
LocalPoint(0,0,0));
344 double dx = rGP.
x()-cscGP.
x(), dy = rGP.
y()-cscGP.
y(), dz = rGP.
z()-cscGP.
z();
345 double distanceN =
sqrt(dx*dx+dy*dy+dz*dz);
348 int En =cscid.
endcap(), Ri=cscid.ring(), St=cscid.station(), Ch=cscid.chamber();
349 if(En==2) En=-1;
if(Ri==4) Ri=1;
351 if((rEn-En)==0 && (rSt-St)==0 && (Ch-rCh) ==0 && rWr!=1 && rSt!=4 && distanceN < distance)
354 distance = distanceN;
355 if(
debug)
std::cout <<
"2\t CSC " <<dtcscid <<
" region : " << En <<
" station : " << St <<
" Ring : " << Ri <<
" chamber : " << Ch <<std::endl;
360 if(dtcscid != 0 && distance < MaxD)
362 rpcrolls2.push_back(*rpcroll);
363 rpcNdtcsc[*rpcroll] = dtcscid;
366 if(
debug)
std::cout <<
"Second step OK!! \n3. Propagate to RPC from DT/CSC!!" << std::endl;
368 std::vector<uint32_t>::iterator rpcroll2;
369 for( rpcroll2=rpcrolls2.begin() ; rpcroll2 < rpcrolls2.end(); rpcroll2++ )
372 std::vector<uint32_t>::iterator rpcput_;
373 for( rpcput_=rpcput.begin() ; rpcput_ < rpcput.end(); rpcput_++ )
374 if(*rpcroll2==*rpcput_) check =
false;
378 uint32_t dtcscid = rpcNdtcsc[*rpcroll2];
382 const GeomDet *geomDet = dtGeo->idToDet(dtcscid);
385 if(dtlayer)
for(Trajectories::const_iterator trajectory = trajectories.begin(); trajectory != trajectories.end(); ++trajectory)
401 if(tInX > rpcGPX || tOuX < rpcGPX )
continue;
402 if(tInY > rpcGPY || tOuY < rpcGPY )
continue;
403 if(tInZ > rpcGPZ || tOuZ < rpcGPZ )
continue;
405 const GeomDet *geomDet2 = rpcGeo->idToDet(*rpcroll2);
410 float rsize = fabs( xmax.
x()-xmin.
x() );
416 if( locx < rsize*eyr && locy < stripl*eyr && locz < 1. )
421 if(
debug)
std::cout <<
"3\t Barrel Expected RPC " << servId.name().c_str() <<
422 " \tLocalposition X: " << locx <<
", Y: "<< locy <<
" GlobalPosition(x,y,z) (" << rpcGPX <<
", "<< rpcGPY <<
", " << rpcGPZ <<
")"<< std::endl;
426 rpcput.push_back(*rpcroll2);
434 const GeomDet *geomDet4 = cscGeo->idToDet(dtcscid);
437 if(csclayer)
for(Trajectories::const_iterator trajectory = trajectories.begin(); trajectory != trajectories.end(); ++trajectory)
453 if(tInX > rpcGPX || tOuX < rpcGPX )
continue;
454 if(tInY > rpcGPY || tOuY < rpcGPY )
continue;
455 if(tInZ > rpcGPZ || tOuZ < rpcGPZ )
continue;
458 const GeomDet *geomDet3 = rpcGeo->idToDet(*rpcroll2);
463 float rsize = fabs( xmax.
x()-xmin.
x() );
470 if( locx < rsize*eyr && locy < stripl*eyr && locz < 1. )
474 if(
debug)
std::cout <<
"3\t Forward Expected RPC " << servId.name().c_str() <<
475 " \tLocalposition X: " << locx <<
", Y: "<< locy <<
" GlobalPosition(x,y,z) (" << rpcGPX <<
", "<< rpcGPY <<
", " << rpcGPZ <<
")"<< std::endl;
479 rpcput.push_back(*rpcroll2);
std::vector< Trajectory > Trajectories
edm::ESHandle< Propagator > thePropagator
std::set< RPCDetId > GetRolls(DTStationIndex2 dtstationindex)
const Topology & topology() const
virtual float stripLength() const
static ObjectMap2CSC * GetInstance(const edm::EventSetup &iSetup)
edm::OwnVector< RPCRecHit > RPCPointVector
LocalPoint localPosition() const
GlobalPoint globalPosition() const
RPCRecHitCollection * _ThePoints
const Plane & surface() const
The nominal surface of the GeomDet.
uint32_t rawId() const
get the raw id
TrackTransformerBase * theTrackTransformer
bool ValidRPCSurface(RPCDetId rpcid, LocalPoint LocalP, const edm::EventSetup &iSetup)
bool check(const DataFrame &df, bool capcheck, bool dvercheck)
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
std::set< RPCDetId > GetRolls(CSCStationIndex2 cscstationindex)
virtual LocalPoint localPosition(float strip) const
int wheel() const
Return the wheel number.
static ObjectMap2 * GetInstance(const edm::EventSetup &iSetup)
virtual float stripLength() const
det heigth (strip length in the middle)