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);
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++ )
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);
407 const RectangularStripTopology* top_=
dynamic_cast<const RectangularStripTopology*
> (&(aroll->
topology()));
410 float rsize = fabs( xmax.
x()-xmin.
x() );
411 float stripl = top_->stripLength();
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);
460 const TrapezoidalStripTopology* top_=
dynamic_cast<const TrapezoidalStripTopology*
>(&(aroll->
topology()));
463 float rsize = fabs( xmax.
x()-xmin.
x() );
464 float stripl = top_->stripLength();
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);
488 if(debug)
std::cout <<
"last steps OK!! " << std::endl;
std::vector< Trajectory > Trajectories
edm::ESHandle< Propagator > thePropagator
std::set< RPCDetId > GetRolls(DTStationIndex2 dtstationindex)
const Topology & topology() const
virtual float length() const =0
ObjectMap2CSC(const edm::EventSetup &iSetup)
static ObjectMap2CSC * GetInstance(const edm::EventSetup &iSetup)
edm::OwnVector< RPCRecHit > RPCPointVector
LocalPoint localPosition() const
GlobalPoint globalPosition() const
static ObjectMap2 * mapInstance
RPCRecHitCollection * _ThePoints
const Plane & surface() const
The nominal surface of the GeomDet.
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)
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)
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
int region() const
Region id: 0 for Barrel, +/-1 For +/- Endcap.