CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
CSCSegtoRPC.cc
Go to the documentation of this file.
13 
15 
17  if (mapInstance == NULL){
18  mapInstance = new ObjectMapCSC(iSetup);
19  }
20  return mapInstance;
21 }
22 
26 
27  iSetup.get<MuonGeometryRecord>().get(rpcGeo);
28  iSetup.get<MuonGeometryRecord>().get(cscGeo);
29 
30  for (TrackingGeometry::DetContainer::const_iterator it=rpcGeo->dets().begin();it<rpcGeo->dets().end();it++){
31  if(dynamic_cast< const RPCChamber* >( *it ) != 0 ){
32  auto ch = dynamic_cast< const RPCChamber* >( *it );
33  std::vector< const RPCRoll*> roles = (ch->rolls());
34  for(std::vector<const RPCRoll*>::const_iterator r = roles.begin();r != roles.end(); ++r){
35  RPCDetId rpcId = (*r)->id();
36  int region=rpcId.region();
37  if(region!=0){
38  int station=rpcId.station();
39  int ring=rpcId.ring();
40  int cscring=ring;
41  int cscstation=station;
42  RPCGeomServ rpcsrv(rpcId);
43  int rpcsegment = rpcsrv.segment();
44  int cscchamber = rpcsegment; //FIX THIS ACCORDING TO RPCGeomServ::segment()Definition
45  if((station==2||station==3)&&ring==3){//Adding Ring 3 of RPC to the CSC Ring 2
46  cscring = 2;
47  }
48  CSCStationIndex ind(region,cscstation,cscring,cscchamber);
49  std::set<RPCDetId> myrolls;
50  if (rollstoreCSC.find(ind)!=rollstoreCSC.end()) myrolls=rollstoreCSC[ind];
51  myrolls.insert(rpcId);
52  rollstoreCSC[ind]=myrolls;
53  }
54  }
55  }
56  }
57 }
58 
59 CSCSegtoRPC::CSCSegtoRPC(edm::Handle<CSCSegmentCollection> allCSCSegments, const edm::EventSetup& iSetup,const edm::Event& iEvent, bool debug, double eyr){
60 
63 
64  iSetup.get<MuonGeometryRecord>().get(rpcGeo);
65  iSetup.get<MuonGeometryRecord>().get(cscGeo);
66 
67  MaxD=80.;
68 
69  if(debug) std::cout<<"CSC \t Number of CSC Segments in this event = "<<allCSCSegments->size()<<std::endl;
70 
72 
73  if(allCSCSegments->size()==0){
74  if(debug) std::cout<<"CSC 0 segments skiping event"<<std::endl;
75  }else {
76  std::map<CSCDetId,int> CSCSegmentsCounter;
78 
79  int segmentsInThisEventInTheEndcap=0;
80 
81  for (segment = allCSCSegments->begin();segment!=allCSCSegments->end(); ++segment){
82  CSCSegmentsCounter[segment->cscDetId()]++;
83  segmentsInThisEventInTheEndcap++;
84  }
85 
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();
89 
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;
93 
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;//Relacion entre las endcaps
100  int rpcRing = cscRing;
101  if(cscRing==4)rpcRing =1;
102  int rpcStation = cscStation;
103  int rpcSegment = CSCId.chamber();
104 
105  LocalPoint segmentPosition= segment->localPosition();
106  LocalVector segmentDirection=segment->localDirection();
107  float dz=segmentDirection.z();
108 
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;
112 
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;
114 
115  if((segment->dimension()==4) && (segment->nRecHits()<=10 && segment->nRecHits()>=4)){
116  //&& acos(dz)*180/3.1415926 > 45. && acos(dz)*180/3.1415926 < 135.){
117  //&& segment->chi2()< ??)Add 3 segmentes in the endcaps???
118 
119 
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;
122 
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();
129 
130  if(debug) std::cout<<"Calling to Object Map class"<<std::endl;
131  ObjectMapCSC* TheObjectCSC = ObjectMapCSC::GetInstance(iSetup);
132  if(debug) std::cout<<"Creating the CSCIndex"<<std::endl;
133  CSCStationIndex theindex(rpcRegion,rpcStation,rpcRing,rpcSegment);
134  if(debug) std::cout<<"Getting the Rolls for the given index"<<std::endl;
135 
136  std::set<RPCDetId> rollsForThisCSC = TheObjectCSC->GetInstance(iSetup)->GetRolls(theindex);
137 
138 
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;
142  const CSCDetId TheId=TheChamber->id();
143 
144  if(debug) std::cout<<"CSC \t \t Number of rolls for this CSC = "<<rollsForThisCSC.size()<<std::endl;
145 
146  if(debug) std::cout<<"CSC \t \t Printing The Id"<<TheId<<std::endl;
147 
148  if(rpcRing!=1&&rpcStation!=4){//They don't exist!
149 
150  assert(rollsForThisCSC.size()>=1);
151 
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);
155  RPCDetId rpcId = rollasociated->id();
156 
157  if(debug) std::cout<<"CSC \t \t \t We are in the roll getting the surface"<<rpcId<<std::endl;
158  const BoundPlane & RPCSurface = rollasociated->surface();
159 
160  if(debug) std::cout<<"CSC \t \t \t RollID: "<<rpcId<<std::endl;
161 
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;
165 
166  GlobalPoint CenterPointRollGlobal = RPCSurface.toGlobal(LocalPoint(0,0,0));
167  if(debug) std::cout<<"CSC \t \t \t Center (0,0,0) of the Roll in Global"<<CenterPointRollGlobal<<std::endl;
168  GlobalPoint CenterPointCSCGlobal = TheChamber->toGlobal(LocalPoint(0,0,0));
169  if(debug) std::cout<<"CSC \t \t \t Center (0,0,0) of the CSC in Global"<<CenterPointCSCGlobal<<std::endl;
170  GlobalPoint segmentPositionInGlobal=TheChamber->toGlobal(segmentPosition); //new way to convert to global
171  if(debug) std::cout<<"CSC \t \t \t Segment Position in Global"<<segmentPositionInGlobal<<std::endl;
172  LocalPoint CenterRollinCSCFrame = TheChamber->toLocal(CenterPointRollGlobal);
173 
174  if(debug){//to check CSC RPC phi relation!
175  float rpcphi=0;
176  float cscphi=0;
177 
178  (CenterPointRollGlobal.barePhi()<0)?
179  rpcphi = 2*3.141592+CenterPointRollGlobal.barePhi():rpcphi=CenterPointRollGlobal.barePhi();
180 
181  (CenterPointCSCGlobal.barePhi()<0)?
182  cscphi = 2*3.1415926536+CenterPointCSCGlobal.barePhi():cscphi=CenterPointCSCGlobal.barePhi();
183 
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;
188 
189  if(debug) std::cout<<"CSC \t \t \t z of RPC="<<CenterPointRollGlobal.z()<<"z of CSC"<<CenterPointCSCGlobal.z()<<" dfg="<<dfg<<std::endl;
190 
191  RPCGeomServ rpcsrv(rpcId);
192 
193  if(dr>200.||fabs(dz)>55.||dfg>1.){
194  //if(rpcRegion==1&&dfg>1.&&dr>100.){
195  if (debug) std::cout
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
204  <<"\t dfg="<<dfg
205  <<" dz="<<diffz
206  <<" dr="<<dr
207  <<std::endl;
208 
209  }
210  }
211 
212  float D=CenterRollinCSCFrame.z();
213 
214  float X=Xo+dx*D/dz;
215  float Y=Yo+dy*D/dz;
216  float Z=D;
217 
218  const TrapezoidalStripTopology* top_=dynamic_cast<const TrapezoidalStripTopology*>(&(rollasociated->topology()));
219  LocalPoint xmin = top_->localPosition(0.);
220  if(debug) std::cout<<"CSC \t \t \t xmin of this Roll "<<xmin<<"cm"<<std::endl;
221  LocalPoint xmax = top_->localPosition((float)rollasociated->nstrips());
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();
227 
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;
230 
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;
234 
235  float extrapolatedDistance = sqrt((X-Xo)*(X-Xo)+(Y-Yo)*(Y-Yo)+(Z-Zo)*(Z-Zo));
236 
237  if(debug) std::cout<<"CSC \t \t \t Is the distance of extrapolation less than MaxD? ="<<extrapolatedDistance<<"cm"<<" MaxD="<<MaxD<<"cm"<<std::endl;
238 
239  if(extrapolatedDistance<=MaxD){
240 
241  if(debug) std::cout<<"CSC \t \t \t yes"<<std::endl;
242 
243  GlobalPoint GlobalPointExtrapolated=TheChamber->toGlobal(LocalPoint(X,Y,Z));
244  if(debug) std::cout<<"CSC \t \t \t Point ExtraPolated in Global"<<GlobalPointExtrapolated<< std::endl;
245 
246 
247  LocalPoint PointExtrapolatedRPCFrame = RPCSurface.toLocal(GlobalPointExtrapolated);
248 
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;
253  if(debug) std::cout<<"CSC \t \t \t dz="
254  <<fabs(PointExtrapolatedRPCFrame.z())<<" dx="
255  <<fabs(PointExtrapolatedRPCFrame.x())<<" dy="
256  <<fabs(PointExtrapolatedRPCFrame.y())<<std::endl;
257 
258  if(debug) std::cout<<"CSC \t \t \t Does the extrapolation go inside this roll????"<<std::endl;
259 
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;
269  RPCPointVector.push_back(RPCPoint);
270  if(debug) std::cout<<"CSC \t \t \t \t Putting the vector"<<std::endl;
272  }
273  }
274  }
275  }
276  }
277  }
278  }
279  }
280 }
281 
283 
284 }
const double Z[kNumberCalorimeter]
int chamber() const
Definition: CSCDetId.h:81
const Topology & topology() const
Definition: RPCRoll.cc:30
T perp() const
Definition: PV3DBase.h:72
CSCDetId id() const
Get the (concrete) DetId.
Definition: CSCChamber.h:37
GlobalPoint toGlobal(const Local2DPoint &lp) const
Conversion to the global R.F. from the R.F. of the GeomDet.
Definition: GeomDet.h:47
int nstrips() const
Definition: RPCRoll.cc:46
T y() const
Definition: PV3DBase.h:63
#define X(str)
Definition: MuonsGrabber.cc:48
LocalPoint toLocal(const GlobalPoint &gp) const
Conversion to the R.F. of the GeomDet.
Definition: GeomDet.h:62
#define NULL
Definition: scimark2.h:8
const Plane & surface() const
The nominal surface of the GeomDet.
Definition: GeomDet.h:35
double MaxD
Definition: CSCSegtoRPC.h:20
iterator begin()
Definition: OwnVector.h:228
int endcap() const
Definition: CSCDetId.h:106
T barePhi() const
Definition: PV3DBase.h:68
void push_back(D *&d)
Definition: OwnVector.h:274
RPCDetId id() const
Definition: RPCRoll.cc:24
int iEvent
Definition: GenABIO.cc:230
int ring() const
Definition: RPCDetId.h:72
T sqrt(T t)
Definition: SSEVec.h:48
T z() const
Definition: PV3DBase.h:64
void clear()
Definition: OwnVector.h:371
static ObjectMapCSC * GetInstance(const edm::EventSetup &iSetup)
Definition: CSCSegtoRPC.cc:16
int ring() const
Definition: CSCDetId.h:88
iterator end()
Definition: OwnVector.h:233
virtual int segment()
Definition: RPCGeomServ.cc:467
RPCRecHitCollection * _ThePoints
Definition: CSCSegtoRPC.h:17
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)
Definition: CSCSegtoRPC.cc:59
#define debug
Definition: HDRShower.cc:19
std::map< CSCStationIndex, std::set< RPCDetId > > rollstoreCSC
Definition: CSCSegtoRPC.h:60
static ObjectMapCSC * mapInstance
Definition: CSCSegtoRPC.h:63
const T & get() const
Definition: EventSetup.h:55
edm::OwnVector< RPCRecHit > RPCPointVector
Definition: CSCSegtoRPC.h:18
ObjectMapCSC(const edm::EventSetup &iSetup)
Definition: CSCSegtoRPC.cc:23
Local3DPoint LocalPoint
Definition: LocalPoint.h:11
int station() const
Definition: CSCDetId.h:99
tuple cout
Definition: gather_cfg.py:121
T x() const
Definition: PV3DBase.h:62
std::set< RPCDetId > GetRolls(CSCStationIndex cscstationindex)
Definition: CSCSegtoRPC.h:58
DecomposeProduct< arg, typename Div::arg > D
Definition: Factorize.h:150
int region() const
Region id: 0 for Barrel, +/-1 For +/- Endcap.
Definition: RPCDetId.h:63
int station() const
Definition: RPCDetId.h:96