30 for (TrackingGeometry::DetContainer::const_iterator it=rpcGeo->dets().begin();it<rpcGeo->dets().end();it++){
31 if(dynamic_cast< RPCChamber* >( *it ) != 0 ){
33 std::vector< const RPCRoll*> roles = (ch->
rolls());
34 for(std::vector<const RPCRoll*>::const_iterator
r = roles.begin();
r != roles.end(); ++
r){
43 int rpcsegment = rpcsrv.
segment();
44 int cscchamber = rpcsegment;
45 if((station==2||station==3)&&ring==3){
49 std::set<RPCDetId> myrolls;
51 myrolls.insert(rpcId);
69 if(debug)
std::cout<<
"CSC \t Number of CSC Segments in this event = "<<allCSCSegments->size()<<std::endl;
73 if(allCSCSegments->size()==0){
74 if(debug)
std::cout<<
"CSC 0 segments skiping event"<<std::endl;
76 std::map<CSCDetId,int> CSCSegmentsCounter;
79 int segmentsInThisEventInTheEndcap=0;
81 for (segment = allCSCSegments->begin();segment!=allCSCSegments->end(); ++segment){
82 CSCSegmentsCounter[segment->cscDetId()]++;
83 segmentsInThisEventInTheEndcap++;
86 if(debug)
std::cout<<
"CSC \t loop over all the CSCSegments "<<std::endl;
87 for (segment = allCSCSegments->begin();segment!=allCSCSegments->end(); ++segment){
88 CSCDetId CSCId = segment->cscDetId();
90 if(debug)
std::cout<<
"CSC \t \t This Segment is in Chamber id: "<<CSCId<<std::endl;
91 if(debug)
std::cout<<
"CSC \t \t Number of segments in this CSC = "<<CSCSegmentsCounter[CSCId]<<std::endl;
92 if(debug)
std::cout<<
"CSC \t \t Is the only one in this CSC? is not ind the ring 1 or station 4? Are there more than 2 segments in the event?"<<std::endl;
94 if(CSCSegmentsCounter[CSCId]==1 && CSCId.
station()!=4 && CSCId.
ring()!=1 && allCSCSegments->size()>=2){
95 if(debug)
std::cout<<
"CSC \t \t yes"<<std::endl;
96 int cscEndCap = CSCId.
endcap();
97 int cscStation = CSCId.
station();
98 int cscRing = CSCId.
ring();
99 int rpcRegion = 1;
if(cscEndCap==2) rpcRegion= -1;
100 int rpcRing = cscRing;
101 if(cscRing==4)rpcRing =1;
102 int rpcStation = cscStation;
103 int rpcSegment = CSCId.
chamber();
105 LocalPoint segmentPosition= segment->localPosition();
106 LocalVector segmentDirection=segment->localDirection();
107 float dz=segmentDirection.
z();
109 if(debug)
std::cout<<
"CSC \t \t \t Information about the segment"
110 <<
"RecHits ="<<segment->nRecHits()
111 <<
"Angle ="<<acos(dz)*180/3.1415926<<std::endl;
113 if(debug)
std::cout<<
"CSC \t \t Is a good Segment? dim = 4, 4 <= nRecHits <= 10 Incident angle int range 45 < "<<acos(dz)*180/3.1415926<<
" < 135? "<<std::endl;
115 if((segment->dimension()==4) && (segment->nRecHits()<=10 && segment->nRecHits()>=4)){
120 if(debug)
std::cout<<
"CSC \t \t yes"<<std::endl;
121 if(debug)
std::cout<<
"CSC \t \t CSC Segment Dimension "<<segment->dimension()<<std::endl;
123 float Xo=segmentPosition.
x();
124 float Yo=segmentPosition.
y();
125 float Zo=segmentPosition.
z();
126 float dx=segmentDirection.
x();
127 float dy=segmentDirection.
y();
128 float dz=segmentDirection.
z();
130 if(debug)
std::cout<<
"Calling to Object Map class"<<std::endl;
132 if(debug)
std::cout<<
"Creating the CSCIndex"<<std::endl;
134 if(debug)
std::cout<<
"Getting the Rolls for the given index"<<std::endl;
136 std::set<RPCDetId> rollsForThisCSC = TheObjectCSC->
GetInstance(iSetup)->
GetRolls(theindex);
139 if(debug)
std::cout<<
"CSC \t \t Getting chamber from Geometry"<<std::endl;
140 const CSCChamber* TheChamber=cscGeo->chamber(CSCId);
141 if(debug)
std::cout<<
"CSC \t \t Getting ID from Chamber"<<std::endl;
144 if(debug)
std::cout<<
"CSC \t \t Number of rolls for this CSC = "<<rollsForThisCSC.size()<<std::endl;
146 if(debug)
std::cout<<
"CSC \t \t Printing The Id"<<TheId<<std::endl;
148 if(rpcRing!=1&&rpcStation!=4){
150 assert(rollsForThisCSC.size()>=1);
152 if(debug)
std::cout<<
"CSC \t \t Loop over all the rolls asociated to this CSC"<<std::endl;
153 for (std::set<RPCDetId>::iterator iteraRoll = rollsForThisCSC.begin();iteraRoll != rollsForThisCSC.end(); iteraRoll++){
154 const RPCRoll* rollasociated = rpcGeo->roll(*iteraRoll);
157 if(debug)
std::cout<<
"CSC \t \t \t We are in the roll getting the surface"<<rpcId<<std::endl;
160 if(debug)
std::cout<<
"CSC \t \t \t RollID: "<<rpcId<<std::endl;
162 if(debug)
std::cout<<
"CSC \t \t \t Doing the extrapolation to this roll"<<std::endl;
163 if(debug)
std::cout<<
"CSC \t \t \t CSC Segment Direction in CSCLocal "<<segmentDirection<<std::endl;
164 if(debug)
std::cout<<
"CSC \t \t \t CSC Segment Point in CSCLocal "<<segmentPosition<<std::endl;
167 if(debug)
std::cout<<
"CSC \t \t \t Center (0,0,0) of the Roll in Global"<<CenterPointRollGlobal<<std::endl;
169 if(debug)
std::cout<<
"CSC \t \t \t Center (0,0,0) of the CSC in Global"<<CenterPointCSCGlobal<<std::endl;
171 if(debug)
std::cout<<
"CSC \t \t \t Segment Position in Global"<<segmentPositionInGlobal<<std::endl;
178 (CenterPointRollGlobal.
barePhi()<0)?
179 rpcphi = 2*3.141592+CenterPointRollGlobal.
barePhi():rpcphi=CenterPointRollGlobal.
barePhi();
181 (CenterPointCSCGlobal.
barePhi()<0)?
182 cscphi = 2*3.1415926536+CenterPointCSCGlobal.
barePhi():cscphi=CenterPointCSCGlobal.
barePhi();
184 float df=fabs(cscphi-rpcphi);
185 float dr=fabs(CenterPointRollGlobal.
perp()-CenterPointCSCGlobal.
perp());
186 float diffz=CenterPointRollGlobal.
z()-CenterPointCSCGlobal.
z();
187 float dfg=df*180./3.14159265;
189 if(debug)
std::cout<<
"CSC \t \t \t z of RPC="<<CenterPointRollGlobal.
z()<<
"z of CSC"<<CenterPointCSCGlobal.
z()<<
" dfg="<<dfg<<std::endl;
193 if(dr>200.||fabs(dz)>55.||dfg>1.){
196 <<
"\t \t \t CSC Station= "<<CSCId.
station()
197 <<
" Ring= "<<CSCId.
ring()
198 <<
" Chamber= "<<CSCId.
chamber()
199 <<
" cscphi="<<cscphi*180/3.14159265
200 <<
"\t RPC Station= "<<rpcId.
station()
201 <<
" ring= "<<rpcId.
ring()
202 <<
" segment =-> "<<rpcsrv.
segment()
203 <<
" rollphi="<<rpcphi*180/3.14159265
212 float D=CenterRollinCSCFrame.
z();
218 const TrapezoidalStripTopology* top_=
dynamic_cast<const TrapezoidalStripTopology*
>(&(rollasociated->
topology()));
220 if(debug)
std::cout<<
"CSC \t \t \t xmin of this Roll "<<xmin<<
"cm"<<std::endl;
222 if(debug)
std::cout<<
"CSC \t \t \t xmax of this Roll "<<xmax<<
"cm"<<std::endl;
223 float rsize = fabs( xmax.
x()-xmin.
x() );
224 if(debug)
std::cout<<
"CSC \t \t \t Roll Size "<<rsize<<
"cm"<<std::endl;
225 float stripl = top_->stripLength();
226 float stripw = top_->pitch();
228 if(debug)
std::cout<<
"CSC \t \t \t Strip Lenght "<<stripl<<
"cm"<<std::endl;
229 if(debug)
std::cout<<
"CSC \t \t \t Strip Width "<<stripw<<
"cm"<<std::endl;
231 if(debug)
std::cout<<
"CSC \t \t \t X Predicted in CSCLocal= "<<X<<
"cm"<<std::endl;
232 if(debug)
std::cout<<
"CSC \t \t \t Y Predicted in CSCLocal= "<<Y<<
"cm"<<std::endl;
233 if(debug)
std::cout<<
"CSC \t \t \t Z Predicted in CSCLocal= "<<Z<<
"cm"<<std::endl;
235 float extrapolatedDistance =
sqrt((X-Xo)*(X-Xo)+(Y-Yo)*(Y-Yo)+(Z-Zo)*(Z-Zo));
237 if(debug)
std::cout<<
"CSC \t \t \t Is the distance of extrapolation less than MaxD? ="<<extrapolatedDistance<<
"cm"<<
" MaxD="<<
MaxD<<
"cm"<<std::endl;
239 if(extrapolatedDistance<=
MaxD){
241 if(debug)
std::cout<<
"CSC \t \t \t yes"<<std::endl;
244 if(debug)
std::cout<<
"CSC \t \t \t Point ExtraPolated in Global"<<GlobalPointExtrapolated<< std::endl;
247 LocalPoint PointExtrapolatedRPCFrame = RPCSurface.toLocal(GlobalPointExtrapolated);
249 if(debug)
std::cout<<
"CSC \t \t \t Point Extrapolated in RPCLocal"<<PointExtrapolatedRPCFrame<< std::endl;
250 if(debug)
std::cout<<
"CSC \t \t \t Corner of the Roll = ("<<rsize*eyr<<
","<<stripl*eyr<<
")"<<std::endl;
251 if(debug)
std::cout<<
"CSC \t \t \t Info About the Point Extrapolated in X Abs ("<<fabs(PointExtrapolatedRPCFrame.
x())<<
","
252 <<fabs(PointExtrapolatedRPCFrame.
y())<<
","<<fabs(PointExtrapolatedRPCFrame.
z())<<
")"<<std::endl;
254 <<fabs(PointExtrapolatedRPCFrame.
z())<<
" dx="
255 <<fabs(PointExtrapolatedRPCFrame.
x())<<
" dy="
256 <<fabs(PointExtrapolatedRPCFrame.
y())<<std::endl;
258 if(debug)
std::cout<<
"CSC \t \t \t Does the extrapolation go inside this roll????"<<std::endl;
260 if(fabs(PointExtrapolatedRPCFrame.
z()) < 1. &&
261 fabs(PointExtrapolatedRPCFrame.
x()) < rsize*eyr &&
262 fabs(PointExtrapolatedRPCFrame.
y()) < stripl*eyr){
263 if(debug)
std::cout<<
"CSC \t \t \t \t yes"<<std::endl;
264 if(debug)
std::cout<<
"CSC \t \t \t \t Creating the RecHit"<<std::endl;
265 RPCRecHit RPCPoint(rpcId,0,PointExtrapolatedRPCFrame);
266 if(debug)
std::cout<<
"CSC \t \t \t \t Clearing the vector"<<std::endl;
268 if(debug)
std::cout<<
"CSC \t \t \t \t Pushing back"<<std::endl;
270 if(debug)
std::cout<<
"CSC \t \t \t \t Putting the vector"<<std::endl;
const double Z[kNumberCalorimeter]
const Topology & topology() const
CSCDetId id() const
Get the (concrete) DetId.
GlobalPoint toGlobal(const Local2DPoint &lp) const
Conversion to the global R.F. from the R.F. of the GeomDet.
LocalPoint toLocal(const GlobalPoint &gp) const
Conversion to the R.F. of the GeomDet.
const Plane & surface() const
The nominal surface of the GeomDet.
const std::vector< const RPCRoll * > & rolls() const
Return the Rolls.
static ObjectMapCSC * GetInstance(const edm::EventSetup &iSetup)
RPCRecHitCollection * _ThePoints
edm::RangeMap< RPCDetId, edm::OwnVector< RPCRecHit, edm::ClonePolicy< RPCRecHit > >, edm::ClonePolicy< RPCRecHit > > RPCRecHitCollection
CSCSegtoRPC(edm::Handle< CSCSegmentCollection > allCSCSegments, const edm::EventSetup &iSetup, const edm::Event &iEvent, bool debug, double eyr)
std::map< CSCStationIndex, std::set< RPCDetId > > rollstoreCSC
static ObjectMapCSC * mapInstance
edm::OwnVector< RPCRecHit > RPCPointVector
ObjectMapCSC(const edm::EventSetup &iSetup)
std::set< RPCDetId > GetRolls(CSCStationIndex cscstationindex)
DecomposeProduct< arg, typename Div::arg > D
int region() const
Region id: 0 for Barrel, +/-1 For +/- Endcap.