27 if(debug)
std::cout<<
"CSC \t Number of CSC Segments in this event = "<<allCSCSegments->size()<<std::endl;
29 _ThePoints = std::make_unique<RPCRecHitCollection>();
31 if(allCSCSegments->size()==0){
32 if(debug)
std::cout<<
"CSC 0 segments skiping event"<<std::endl;
34 std::map<CSCDetId,int> CSCSegmentsCounter;
37 int segmentsInThisEventInTheEndcap=0;
39 for (segment = allCSCSegments->begin();segment!=allCSCSegments->end(); ++segment){
40 CSCSegmentsCounter[segment->cscDetId()]++;
41 segmentsInThisEventInTheEndcap++;
44 if(debug)
std::cout<<
"CSC \t loop over all the CSCSegments "<<std::endl;
45 for (segment = allCSCSegments->begin();segment!=allCSCSegments->end(); ++segment){
46 CSCDetId CSCId = segment->cscDetId();
48 if(debug)
std::cout<<
"CSC \t \t This Segment is in Chamber id: "<<CSCId<<std::endl;
49 if(debug)
std::cout<<
"CSC \t \t Number of segments in this CSC = "<<CSCSegmentsCounter[CSCId]<<std::endl;
50 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;
52 if(CSCSegmentsCounter[CSCId]==1 && CSCId.
station()!=4 && CSCId.
ring()!=1 && allCSCSegments->size()>=2){
53 if(debug)
std::cout<<
"CSC \t \t yes"<<std::endl;
54 int cscEndCap = CSCId.
endcap();
55 int cscStation = CSCId.
station();
56 int cscRing = CSCId.
ring();
57 int rpcRegion = 1;
if(cscEndCap==2) rpcRegion= -1;
58 int rpcRing = cscRing;
59 if(cscRing==4)rpcRing =1;
60 int rpcStation = cscStation;
61 int rpcSegment = CSCId.
chamber();
63 LocalPoint segmentPosition= segment->localPosition();
64 LocalVector segmentDirection=segment->localDirection();
65 float dz=segmentDirection.
z();
67 if(debug)
std::cout<<
"CSC \t \t \t Information about the segment" 68 <<
"RecHits ="<<segment->nRecHits()
69 <<
"Angle ="<<acos(dz)*180/3.1415926<<std::endl;
71 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;
73 if((segment->dimension()==4) && (segment->nRecHits()<=10 && segment->nRecHits()>=4)){
78 if(debug)
std::cout<<
"CSC \t \t yes"<<std::endl;
79 if(debug)
std::cout<<
"CSC \t \t CSC Segment Dimension "<<segment->dimension()<<std::endl;
81 float Xo=segmentPosition.
x();
82 float Yo=segmentPosition.
y();
83 float Zo=segmentPosition.
z();
84 float dx=segmentDirection.
x();
85 float dy=segmentDirection.
y();
86 float dz=segmentDirection.
z();
88 if(debug)
std::cout<<
"Creating the CSCIndex"<<std::endl;
90 if(debug)
std::cout<<
"Getting the Rolls for the given index"<<std::endl;
91 std::set<RPCDetId> rollsForThisCSC = cscMap->
getRolls(theindex);
92 if(debug)
std::cout<<
"CSC \t \t Getting chamber from Geometry"<<std::endl;
94 if(debug)
std::cout<<
"CSC \t \t Getting ID from Chamber"<<std::endl;
97 if(debug)
std::cout<<
"CSC \t \t Number of rolls for this CSC = "<<rollsForThisCSC.size()<<std::endl;
99 if(debug)
std::cout<<
"CSC \t \t Printing The Id"<<TheId<<std::endl;
101 if(rpcRing!=1&&rpcStation!=4){
103 assert(rollsForThisCSC.size()>=1);
105 if(debug)
std::cout<<
"CSC \t \t Loop over all the rolls asociated to this CSC"<<std::endl;
106 for (std::set<RPCDetId>::iterator iteraRoll = rollsForThisCSC.begin();iteraRoll != rollsForThisCSC.end(); iteraRoll++){
107 const RPCRoll* rollasociated = rpcGeo->
roll(*iteraRoll);
110 if(debug)
std::cout<<
"CSC \t \t \t We are in the roll getting the surface"<<rpcId<<std::endl;
113 if(debug)
std::cout<<
"CSC \t \t \t RollID: "<<rpcId<<std::endl;
115 if(debug)
std::cout<<
"CSC \t \t \t Doing the extrapolation to this roll"<<std::endl;
116 if(debug)
std::cout<<
"CSC \t \t \t CSC Segment Direction in CSCLocal "<<segmentDirection<<std::endl;
117 if(debug)
std::cout<<
"CSC \t \t \t CSC Segment Point in CSCLocal "<<segmentPosition<<std::endl;
120 if(debug)
std::cout<<
"CSC \t \t \t Center (0,0,0) of the Roll in Global"<<CenterPointRollGlobal<<std::endl;
122 if(debug)
std::cout<<
"CSC \t \t \t Center (0,0,0) of the CSC in Global"<<CenterPointCSCGlobal<<std::endl;
124 if(debug)
std::cout<<
"CSC \t \t \t Segment Position in Global"<<segmentPositionInGlobal<<std::endl;
131 (CenterPointRollGlobal.
barePhi()<0)?
132 rpcphi = 2*3.141592+CenterPointRollGlobal.
barePhi():rpcphi=CenterPointRollGlobal.
barePhi();
134 (CenterPointCSCGlobal.
barePhi()<0)?
135 cscphi = 2*3.1415926536+CenterPointCSCGlobal.
barePhi():cscphi=CenterPointCSCGlobal.
barePhi();
137 float df=fabs(cscphi-rpcphi);
138 float dr=fabs(CenterPointRollGlobal.
perp()-CenterPointCSCGlobal.
perp());
139 float diffz=CenterPointRollGlobal.
z()-CenterPointCSCGlobal.
z();
140 float dfg=df*180./3.14159265;
142 if(debug)
std::cout<<
"CSC \t \t \t z of RPC="<<CenterPointRollGlobal.
z()<<
"z of CSC"<<CenterPointCSCGlobal.
z()<<
" dfg="<<dfg<<std::endl;
146 if(dr>200.||fabs(dz)>55.||dfg>1.){
149 <<
"\t \t \t CSC Station= "<<CSCId.
station()
150 <<
" Ring= "<<CSCId.
ring()
151 <<
" Chamber= "<<CSCId.
chamber()
152 <<
" cscphi="<<cscphi*180/3.14159265
153 <<
"\t RPC Station= "<<rpcId.
station()
154 <<
" ring= "<<rpcId.
ring()
155 <<
" segment =-> "<<rpcsrv.
segment()
156 <<
" rollphi="<<rpcphi*180/3.14159265
165 float D=CenterRollinCSCFrame.
z();
173 if(debug)
std::cout<<
"CSC \t \t \t xmin of this Roll "<<xmin<<
"cm"<<std::endl;
175 if(debug)
std::cout<<
"CSC \t \t \t xmax of this Roll "<<xmax<<
"cm"<<std::endl;
176 float rsize = fabs( xmax.
x()-xmin.
x() );
177 if(debug)
std::cout<<
"CSC \t \t \t Roll Size "<<rsize<<
"cm"<<std::endl;
179 float stripw = top_->
pitch();
181 if(debug)
std::cout<<
"CSC \t \t \t Strip Lenght "<<stripl<<
"cm"<<std::endl;
182 if(debug)
std::cout<<
"CSC \t \t \t Strip Width "<<stripw<<
"cm"<<std::endl;
184 if(debug)
std::cout<<
"CSC \t \t \t X Predicted in CSCLocal= "<<X<<
"cm"<<std::endl;
185 if(debug)
std::cout<<
"CSC \t \t \t Y Predicted in CSCLocal= "<<Y<<
"cm"<<std::endl;
186 if(debug)
std::cout<<
"CSC \t \t \t Z Predicted in CSCLocal= "<<Z<<
"cm"<<std::endl;
188 float extrapolatedDistance =
sqrt((X-Xo)*(X-Xo)+(Y-Yo)*(Y-Yo)+(Z-Zo)*(Z-Zo));
190 if(debug)
std::cout<<
"CSC \t \t \t Is the distance of extrapolation less than MaxD? ="<<extrapolatedDistance<<
"cm"<<
" MaxD="<<
MaxD<<
"cm"<<std::endl;
192 if(extrapolatedDistance<=
MaxD){
194 if(debug)
std::cout<<
"CSC \t \t \t yes"<<std::endl;
197 if(debug)
std::cout<<
"CSC \t \t \t Point ExtraPolated in Global"<<GlobalPointExtrapolated<< std::endl;
200 LocalPoint PointExtrapolatedRPCFrame = RPCSurface.toLocal(GlobalPointExtrapolated);
202 if(debug)
std::cout<<
"CSC \t \t \t Point Extrapolated in RPCLocal"<<PointExtrapolatedRPCFrame<< std::endl;
203 if(debug)
std::cout<<
"CSC \t \t \t Corner of the Roll = ("<<rsize*eyr<<
","<<stripl*eyr<<
")"<<std::endl;
204 if(debug)
std::cout<<
"CSC \t \t \t Info About the Point Extrapolated in X Abs ("<<fabs(PointExtrapolatedRPCFrame.
x())<<
"," 205 <<fabs(PointExtrapolatedRPCFrame.
y())<<
","<<fabs(PointExtrapolatedRPCFrame.
z())<<
")"<<std::endl;
207 <<fabs(PointExtrapolatedRPCFrame.
z())<<
" dx=" 208 <<fabs(PointExtrapolatedRPCFrame.
x())<<
" dy=" 209 <<fabs(PointExtrapolatedRPCFrame.
y())<<std::endl;
211 if(debug)
std::cout<<
"CSC \t \t \t Does the extrapolation go inside this roll????"<<std::endl;
213 if(fabs(PointExtrapolatedRPCFrame.
z()) < 1. &&
214 fabs(PointExtrapolatedRPCFrame.
x()) < rsize*eyr &&
215 fabs(PointExtrapolatedRPCFrame.
y()) < stripl*eyr){
216 if(debug)
std::cout<<
"CSC \t \t \t \t yes"<<std::endl;
217 if(debug)
std::cout<<
"CSC \t \t \t \t Creating the RecHit"<<std::endl;
218 RPCRecHit RPCPoint(rpcId,0,PointExtrapolatedRPCFrame);
219 if(debug)
std::cout<<
"CSC \t \t \t \t Clearing the vector"<<std::endl;
221 if(debug)
std::cout<<
"CSC \t \t \t \t Pushing back"<<std::endl;
223 if(debug)
std::cout<<
"CSC \t \t \t \t Putting the vector"<<std::endl;
const Topology & topology() const
Point3DBase< Scalar, LocalTag > LocalPoint
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.
std::set< RPCDetId > const & getRolls(CSCStationIndex index) const
const Plane & surface() const
The nominal surface of the GeomDet.
virtual float pitch() const
std::unique_ptr< RPCRecHitCollection > _ThePoints
CSCSegtoRPC(CSCSegmentCollection const *allCSCSegments, edm::EventSetup const &iSetup, bool debug, double eyr)
DecomposeProduct< arg, typename Div::arg > D
const CSCChamber * chamber(CSCDetId id) const
Return the chamber corresponding to given DetId.
edm::OwnVector< RPCRecHit > RPCPointVector
virtual LocalPoint localPosition(float strip) const
virtual float stripLength() const
det heigth (strip length in the middle)
const RPCRoll * roll(RPCDetId id) const
Return a roll given its id.