35 for (TrackingGeometry::DetContainer::const_iterator it=rpcGeo->dets().begin();it<rpcGeo->dets().end();it++){
36 if(dynamic_cast< RPCChamber* >( *it ) != 0 ){
38 std::vector< const RPCRoll*> roles = (ch->
rolls());
39 for(std::vector<const RPCRoll*>::const_iterator
r = roles.begin();
r != roles.end(); ++
r){
43 int wheel=rpcId.
ring();
47 std::set<RPCDetId> myrolls;
49 myrolls.insert(rpcId);
58 if(sector1==13) sector1=4;
59 if(sector1==14) sector1=10;
61 if(sector2==13) sector2=4;
62 if(sector2==14) sector2=10;
64 int distance =
std::abs(sector1 - sector2);
65 if(distance>6) distance = 12-distance;
70 int distance =
std::abs(wheel1 - wheel2);
89 for (TrackingGeometry::DetContainer::const_iterator it=rpcGeo->dets().begin();it<rpcGeo->dets().end();it++){
90 if(dynamic_cast< RPCChamber* >( *it ) != 0 ){
92 std::vector< const RPCRoll*> roles = (ch->
rolls());
93 for(std::vector<const RPCRoll*>::const_iterator
r = roles.begin();
r != roles.end(); ++
r){
102 int rpcsegment = rpcsrv.
segment();
103 int cscchamber = rpcsegment;
104 if((station==2||station==3)&&ring==3){
108 std::set<RPCDetId> myrolls;
110 myrolls.insert(rpcId);
123 const GeomDet *whichdet3 = rpcGeo->idToDet(rpcid.
rawId());
125 float locx=LocalP.
x(), locy=LocalP.
y();
128 const Bounds &rollbound = rpcGeo->idToDet((rpcid))->surface().bounds();
129 float boundlength = rollbound.
length();
130 float boundwidth = rollbound.
width();
132 if(fabs(locx) < boundwidth/2 && fabs(locy) < boundlength/2 && locy > -boundlength/2)
return true;
138 const Bounds &rollbound = rpcGeo->idToDet((rpcid))->surface().bounds();
139 float boundlength = rollbound.
length();
140 float boundwidth = rollbound.
width();
143 float ylimit = ((boundlength)/(boundwidth/2 - nminx/2))*fabs(locx) + boundlength/2 - ((boundlength)/(boundwidth/2 - nminx/2))*(boundwidth/2);
144 if(ylimit < -boundlength/2 ) ylimit = -boundlength/2;
146 if(fabs(locx) < boundwidth/2 && fabs(locy) < boundlength/2 && locy > ylimit)
return true;
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);
231 rpcrollCounter[rollasociated->
id().
rawId()]++;
233 std::vector<uint32_t>::iterator rpcroll;
234 for( rpcroll=rpcrolls.begin() ; rpcroll < rpcrolls.end(); rpcroll++ )
235 if(rollasociated->
id().
rawId()== *rpcroll) check=
false;
238 rpcrolls.push_back(rollasociated->
id().
rawId());
240 if(debug)
std::cout <<
"1\t Barrel RPC roll" << rollasociated->
id().
rawId() <<
" "<< servId.name().c_str() <<std::endl;
249 const GeomDet *geomDet = cscGeo->idToDet((*hit)->geographicalId());
253 if(csclayer)
for(Trajectories::const_iterator trajectory = trajectories.begin(); trajectory != trajectories.end(); ++trajectory)
261 if(upd2.
isValid() && cscid.station()!=4 && cscid.ring()!=1 )
265 float dx = trajLP.
x()-trackLP.
x(), dy=trajLP.
y()-trackLP.
y();
266 if( dx>10. && dy>10.)
continue;
269 int En = cscid.endcap(), St = cscid.station(), Ri = cscid.ring();
270 int rpcSegment = cscid.chamber();
271 if(En==2) En= -1;
if(Ri==4) Ri =1;
274 std::set<RPCDetId> rollsForThisCSC = TheObjectCSC->
GetInstance(iSetup)->
GetRolls(theindex);
275 for (std::set<RPCDetId>::iterator iteraRoll = rollsForThisCSC.begin();iteraRoll != rollsForThisCSC.end(); iteraRoll++)
277 const RPCRoll* rollasociated = rpcGeo->roll(*iteraRoll);
283 rpcrollCounter[rollasociated->
id().
rawId()]++;
285 std::vector<uint32_t>::iterator rpcroll;
286 for( rpcroll=rpcrolls.begin() ; rpcroll < rpcrolls.end(); rpcroll++ )
287 if(rollasociated->
id().
rawId()==*rpcroll) check=
false;
290 rpcrolls.push_back(rollasociated->
id().
rawId());
292 if(debug)
std::cout <<
"1\t Forward RPC roll" << rollasociated->
id().
rawId() <<
" "<< servId.name().c_str() <<std::endl;
298 }
else {
if(debug)
std::cout <<
"1\t The hit is not DT/CSC's. " << std::endl;}
301 if(debug)
std::cout <<
"First step OK!!\n2. Search nearest DT/CSC sufrace!!" << std::endl;
302 std::vector<uint32_t>::iterator rpcroll;
303 for( rpcroll=rpcrolls.begin() ; rpcroll < rpcrolls.end(); rpcroll++ )
310 if(rpcrollCounter[*rpcroll]<3) continue ;
312 uint32_t dtcscid=0;
double distance=
MaxD;
319 if((*hit)->isValid())
321 DetId id = (*hit)->geographicalId();
324 const GeomDet *geomDet = dtGeo->idToDet((*hit)->geographicalId());
326 const GlobalPoint &dtGP = dtGeo->idToDet((*hit)->geographicalId())->surface().toGlobal(
LocalPoint(0,0,0));
327 double dx = rGP.
x()-dtGP.
x(), dy = rGP.
y()-dtGP.
y(), dz = rGP.
z()-dtGP.
z();
328 double distanceN =
sqrt(dx*dx+dy*dy+dz*dz);
331 int Se = dtid.
sector(), Wh = dtid.wheel(), St = dtid.station();
332 if(Se == 13) Se=4;
if(Se ==14) Se=10;
334 if( rEn==0&& (rSe-Se)==0 && (rWr-Wh) ==0 && (rSt-St)==0 && distanceN < distance)
337 distance = distanceN;
338 if(debug)
std::cout <<
"2\t DT "<< dtcscid <<
" Wheel : " << Wh <<
" station : " << St <<
" sector : " << Se << std::endl;
343 const GeomDet *geomDet = cscGeo->idToDet((*hit)->geographicalId());
345 const GlobalPoint &cscGP = cscGeo->idToDet((*hit)->geographicalId())->surface().toGlobal(
LocalPoint(0,0,0));
346 double dx = rGP.
x()-cscGP.
x(), dy = rGP.
y()-cscGP.
y(), dz = rGP.
z()-cscGP.
z();
347 double distanceN =
sqrt(dx*dx+dy*dy+dz*dz);
350 int En =cscid.
endcap(), Ri=cscid.ring(), St=cscid.station(), Ch=cscid.chamber();
351 if(En==2) En=-1;
if(Ri==4) Ri=1;
353 if((rEn-En)==0 && (rSt-St)==0 && (Ch-rCh) ==0 && rWr!=1 && rSt!=4 && distanceN < distance)
356 distance = distanceN;
357 if(debug)
std::cout <<
"2\t CSC " <<dtcscid <<
" region : " << En <<
" station : " << St <<
" Ring : " << Ri <<
" chamber : " << Ch <<std::endl;
362 if(dtcscid != 0 && distance < MaxD)
364 rpcrolls2.push_back(*rpcroll);
365 rpcNdtcsc[*rpcroll] = dtcscid;
368 if(debug)
std::cout <<
"Second step OK!! \n3. Propagate to RPC from DT/CSC!!" << std::endl;
370 std::vector<uint32_t>::iterator rpcroll2;
371 for( rpcroll2=rpcrolls2.begin() ; rpcroll2 < rpcrolls2.end(); rpcroll2++ )
374 std::vector<uint32_t>::iterator rpcput_;
375 for( rpcput_=rpcput.begin() ; rpcput_ < rpcput.end(); rpcput_++ )
376 if(*rpcroll2==*rpcput_) check =
false;
380 uint32_t dtcscid = rpcNdtcsc[*rpcroll2];
384 const GeomDet *geomDet = dtGeo->idToDet(dtcscid);
387 if(dtlayer)
for(Trajectories::const_iterator trajectory = trajectories.begin(); trajectory != trajectories.end(); ++trajectory)
403 if(tInX > rpcGPX || tOuX < rpcGPX )
continue;
404 if(tInY > rpcGPY || tOuY < rpcGPY )
continue;
405 if(tInZ > rpcGPZ || tOuZ < rpcGPZ )
continue;
407 const GeomDet *geomDet2 = rpcGeo->idToDet(*rpcroll2);
412 float rsize = fabs( xmax.
x()-xmin.
x() );
418 if( locx < rsize*eyr && locy < stripl*eyr && locz < 1. )
423 if(debug)
std::cout <<
"3\t Barrel Expected RPC " << servId.
name().c_str() <<
424 " \tLocalposition X: " << locx <<
", Y: "<< locy <<
" GlobalPosition(x,y,z) (" << rpcGPX <<
", "<< rpcGPY <<
", " << rpcGPZ <<
")"<< std::endl;
428 rpcput.push_back(*rpcroll2);
436 const GeomDet *geomDet4 = cscGeo->idToDet(dtcscid);
439 if(csclayer)
for(Trajectories::const_iterator trajectory = trajectories.begin(); trajectory != trajectories.end(); ++trajectory)
455 if(tInX > rpcGPX || tOuX < rpcGPX )
continue;
456 if(tInY > rpcGPY || tOuY < rpcGPY )
continue;
457 if(tInZ > rpcGPZ || tOuZ < rpcGPZ )
continue;
460 const GeomDet *geomDet3 = rpcGeo->idToDet(*rpcroll2);
465 float rsize = fabs( xmax.
x()-xmin.
x() );
472 if( locx < rsize*eyr && locy < stripl*eyr && locz < 1. )
476 if(debug)
std::cout <<
"3\t Forward Expected RPC " << servId.
name().c_str() <<
477 " \tLocalposition X: " << locx <<
", Y: "<< locy <<
" GlobalPosition(x,y,z) (" << rpcGPX <<
", "<< rpcGPY <<
", " << rpcGPZ <<
")"<< std::endl;
481 rpcput.push_back(*rpcroll2);
490 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
std::set< RPCDetId > GetRolls(DTStationIndex2 dtstationindex)
const Topology & topology() const
virtual float length() const =0
ObjectMap2CSC(const edm::EventSetup &iSetup)
virtual float stripLength() const
static ObjectMap2CSC * GetInstance(const edm::EventSetup &iSetup)
edm::OwnVector< RPCRecHit > RPCPointVector
LocalPoint localPosition() const
GlobalPoint globalPosition() const
static ObjectMap2 * mapInstance
RPCRecHitCollection * _ThePoints
uint32_t rawId() const
get the raw id
TrackTransformerBase * theTrackTransformer
std::map< DTStationIndex2, std::set< RPCDetId > > rollstoreDT
virtual std::string name()
bool ValidRPCSurface(RPCDetId rpcid, LocalPoint LocalP, const edm::EventSetup &iSetup)
bool check(const DataFrame &df, bool capcheck, bool dvercheck)
int distwheel2(int wheel1, int wheel2)
const std::vector< const RPCRoll * > & rolls() const
Return the Rolls.
DetId geographicalId() const
The label of this GeomDet.
static ObjectMap2CSC * mapInstance
ObjectMap2(const edm::EventSetup &iSetup)
edm::RangeMap< RPCDetId, edm::OwnVector< RPCRecHit, edm::ClonePolicy< RPCRecHit > >, edm::ClonePolicy< RPCRecHit > > RPCRecHitCollection
int distsector2(int sector1, int sector2)
virtual LocalPoint localPosition(float strip) const
int sector() const
Sector id: the group of chambers at same phi (and increasing r)
std::set< RPCDetId > GetRolls(CSCStationIndex2 cscstationindex)
TracktoRPC(edm::Handle< reco::TrackCollection > alltracks, const edm::EventSetup &iSetup, const edm::Event &iEvent, bool debug, const edm::ParameterSet &iConfig, edm::InputTag &tracklabel)
virtual LocalPoint localPosition(float strip) const
std::map< CSCStationIndex2, std::set< RPCDetId > > rollstoreCSC
int wheel() const
Return the wheel number.
static ObjectMap2 * GetInstance(const edm::EventSetup &iSetup)
virtual float width() const =0
virtual float stripLength() const
det heigth (strip length in the middle)
virtual const BoundPlane & surface() const
The nominal surface of the GeomDet.
int region() const
Region id: 0 for Barrel, +/-1 For +/- Endcap.