CMS 3D CMS Logo

List of all members | Public Member Functions | Private Attributes
CSCSegtoRPC Class Reference

#include <CSCSegtoRPC.h>

Public Member Functions

 CSCSegtoRPC (CSCSegmentCollection const *allCSCSegments, edm::EventSetup const &iSetup, bool debug, double eyr)
 
std::unique_ptr< RPCRecHitCollection > && thePoints ()
 
 ~CSCSegtoRPC ()
 

Private Attributes

std::unique_ptr< RPCRecHitCollection_ThePoints
 
bool inclcsc
 
double MaxD
 
edm::OwnVector< RPCRecHitRPCPointVector
 

Detailed Description

Definition at line 13 of file CSCSegtoRPC.h.

Constructor & Destructor Documentation

CSCSegtoRPC::CSCSegtoRPC ( CSCSegmentCollection const *  allCSCSegments,
edm::EventSetup const &  iSetup,
bool  debug,
double  eyr 
)

Definition at line 15 of file CSCSegtoRPC.cc.

References _ThePoints, PV3DBase< T, PVType, FrameType >::barePhi(), edm::OwnVector< T, P >::begin(), CSCDetId::chamber(), CSCGeometry::chamber(), edm::OwnVector< T, P >::clear(), gather_cfg::cout, flavorHistoryFilter_cfi::dr, PVValHelper::dx, PVValHelper::dy, PVValHelper::dz, edm::OwnVector< T, P >::end(), CSCDetId::endcap(), edm::EventSetup::get(), CSCObjectMap::getRolls(), RPCRoll::id(), CSCChamber::id(), TrapezoidalStripTopology::localPosition(), MaxD, RPCRoll::nstrips(), PV3DBase< T, PVType, FrameType >::perp(), TrapezoidalStripTopology::pitch(), edm::OwnVector< T, P >::push_back(), RPCDetId::ring(), CSCDetId::ring(), RPCGeometry::roll(), RPCPointVector, RPCGeomServ::segment(), mathSSE::sqrt(), RPCDetId::station(), CSCDetId::station(), TrapezoidalStripTopology::stripLength(), GeomDet::surface(), GeomDet::toGlobal(), GeomDet::toLocal(), RPCRoll::topology(), X, PV3DBase< T, PVType, FrameType >::x(), TrackerOfflineValidation_Dqm_cff::xmax, TrackerOfflineValidation_Dqm_cff::xmin, DOFs::Y, PV3DBase< T, PVType, FrameType >::y(), DOFs::Z, and PV3DBase< T, PVType, FrameType >::z().

18  {
22 
23  iSetup.get<MuonGeometryRecord>().get(rpcGeo);
24  iSetup.get<MuonGeometryRecord>().get(cscGeo);
25  iSetup.get<MuonGeometryRecord>().get(cscMap);
26 
27  MaxD = 80.;
28 
29  if (debug)
30  std::cout << "CSC \t Number of CSC Segments in this event = " << allCSCSegments->size() << std::endl;
31 
32  _ThePoints = std::make_unique<RPCRecHitCollection>();
33 
34  if (allCSCSegments->size() == 0) {
35  if (debug)
36  std::cout << "CSC 0 segments skiping event" << std::endl;
37  } else {
38  std::map<CSCDetId, int> CSCSegmentsCounter;
40 
41  int segmentsInThisEventInTheEndcap = 0;
42 
43  for (segment = allCSCSegments->begin(); segment != allCSCSegments->end(); ++segment) {
44  CSCSegmentsCounter[segment->cscDetId()]++;
45  segmentsInThisEventInTheEndcap++;
46  }
47 
48  if (debug)
49  std::cout << "CSC \t loop over all the CSCSegments " << std::endl;
50  for (segment = allCSCSegments->begin(); segment != allCSCSegments->end(); ++segment) {
51  CSCDetId CSCId = segment->cscDetId();
52 
53  if (debug)
54  std::cout << "CSC \t \t This Segment is in Chamber id: " << CSCId << std::endl;
55  if (debug)
56  std::cout << "CSC \t \t Number of segments in this CSC = " << CSCSegmentsCounter[CSCId] << std::endl;
57  if (debug)
58  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 "
59  "segments in the event?"
60  << std::endl;
61 
62  if (CSCSegmentsCounter[CSCId] == 1 && CSCId.station() != 4 && CSCId.ring() != 1 && allCSCSegments->size() >= 2) {
63  if (debug)
64  std::cout << "CSC \t \t yes" << std::endl;
65  int cscEndCap = CSCId.endcap();
66  int cscStation = CSCId.station();
67  int cscRing = CSCId.ring();
68  int rpcRegion = 1;
69  if (cscEndCap == 2)
70  rpcRegion = -1; //Relacion entre las endcaps
71  int rpcRing = cscRing;
72  if (cscRing == 4)
73  rpcRing = 1;
74  int rpcStation = cscStation;
75  int rpcSegment = CSCId.chamber();
76 
77  LocalPoint segmentPosition = segment->localPosition();
78  LocalVector segmentDirection = segment->localDirection();
79  float dz = segmentDirection.z();
80 
81  if (debug)
82  std::cout << "CSC \t \t \t Information about the segment"
83  << "RecHits =" << segment->nRecHits() << "Angle =" << acos(dz) * 180 / 3.1415926 << std::endl;
84 
85  if (debug)
86  std::cout << "CSC \t \t Is a good Segment? dim = 4, 4 <= nRecHits <= 10 Incident angle int range 45 < "
87  << acos(dz) * 180 / 3.1415926 << " < 135? " << std::endl;
88 
89  if ((segment->dimension() == 4) && (segment->nRecHits() <= 10 && segment->nRecHits() >= 4)) {
90  //&& acos(dz)*180/3.1415926 > 45. && acos(dz)*180/3.1415926 < 135.){
91  //&& segment->chi2()< ??)Add 3 segmentes in the endcaps???
92 
93  if (debug)
94  std::cout << "CSC \t \t yes" << std::endl;
95  if (debug)
96  std::cout << "CSC \t \t CSC Segment Dimension " << segment->dimension() << std::endl;
97 
98  float Xo = segmentPosition.x();
99  float Yo = segmentPosition.y();
100  float Zo = segmentPosition.z();
101  float dx = segmentDirection.x();
102  float dy = segmentDirection.y();
103  float dz = segmentDirection.z();
104 
105  if (debug)
106  std::cout << "Creating the CSCIndex" << std::endl;
107  CSCStationIndex theindex(rpcRegion, rpcStation, rpcRing, rpcSegment);
108  if (debug)
109  std::cout << "Getting the Rolls for the given index" << std::endl;
110  std::set<RPCDetId> rollsForThisCSC = cscMap->getRolls(theindex);
111  if (debug)
112  std::cout << "CSC \t \t Getting chamber from Geometry" << std::endl;
113  const CSCChamber* TheChamber = cscGeo->chamber(CSCId);
114  if (debug)
115  std::cout << "CSC \t \t Getting ID from Chamber" << std::endl;
116  const CSCDetId TheId = TheChamber->id();
117 
118  if (debug)
119  std::cout << "CSC \t \t Number of rolls for this CSC = " << rollsForThisCSC.size() << std::endl;
120 
121  if (debug)
122  std::cout << "CSC \t \t Printing The Id" << TheId << std::endl;
123 
124  if (rpcRing != 1 && rpcStation != 4) { //They don't exist!
125 
126  assert(!rollsForThisCSC.empty());
127 
128  if (debug)
129  std::cout << "CSC \t \t Loop over all the rolls asociated to this CSC" << std::endl;
130  for (std::set<RPCDetId>::iterator iteraRoll = rollsForThisCSC.begin(); iteraRoll != rollsForThisCSC.end();
131  iteraRoll++) {
132  const RPCRoll* rollasociated = rpcGeo->roll(*iteraRoll);
133  RPCDetId rpcId = rollasociated->id();
134 
135  if (debug)
136  std::cout << "CSC \t \t \t We are in the roll getting the surface" << rpcId << std::endl;
137  const BoundPlane& RPCSurface = rollasociated->surface();
138 
139  if (debug)
140  std::cout << "CSC \t \t \t RollID: " << rpcId << std::endl;
141 
142  if (debug)
143  std::cout << "CSC \t \t \t Doing the extrapolation to this roll" << std::endl;
144  if (debug)
145  std::cout << "CSC \t \t \t CSC Segment Direction in CSCLocal " << segmentDirection << std::endl;
146  if (debug)
147  std::cout << "CSC \t \t \t CSC Segment Point in CSCLocal " << segmentPosition << std::endl;
148 
149  GlobalPoint CenterPointRollGlobal = RPCSurface.toGlobal(LocalPoint(0, 0, 0));
150  if (debug)
151  std::cout << "CSC \t \t \t Center (0,0,0) of the Roll in Global" << CenterPointRollGlobal << std::endl;
152  GlobalPoint CenterPointCSCGlobal = TheChamber->toGlobal(LocalPoint(0, 0, 0));
153  if (debug)
154  std::cout << "CSC \t \t \t Center (0,0,0) of the CSC in Global" << CenterPointCSCGlobal << std::endl;
155  GlobalPoint segmentPositionInGlobal =
156  TheChamber->toGlobal(segmentPosition); //new way to convert to global
157  if (debug)
158  std::cout << "CSC \t \t \t Segment Position in Global" << segmentPositionInGlobal << std::endl;
159  LocalPoint CenterRollinCSCFrame = TheChamber->toLocal(CenterPointRollGlobal);
160 
161  if (debug) { //to check CSC RPC phi relation!
162  float rpcphi = 0;
163  float cscphi = 0;
164 
165  (CenterPointRollGlobal.barePhi() < 0) ? rpcphi = 2 * 3.141592 + CenterPointRollGlobal.barePhi()
166  : rpcphi = CenterPointRollGlobal.barePhi();
167 
168  (CenterPointCSCGlobal.barePhi() < 0) ? cscphi = 2 * 3.1415926536 + CenterPointCSCGlobal.barePhi()
169  : cscphi = CenterPointCSCGlobal.barePhi();
170 
171  float df = fabs(cscphi - rpcphi);
172  float dr = fabs(CenterPointRollGlobal.perp() - CenterPointCSCGlobal.perp());
173  float diffz = CenterPointRollGlobal.z() - CenterPointCSCGlobal.z();
174  float dfg = df * 180. / 3.14159265;
175 
176  if (debug)
177  std::cout << "CSC \t \t \t z of RPC=" << CenterPointRollGlobal.z() << "z of CSC"
178  << CenterPointCSCGlobal.z() << " dfg=" << dfg << std::endl;
179 
180  RPCGeomServ rpcsrv(rpcId);
181 
182  if (dr > 200. || fabs(dz) > 55. || dfg > 1.) {
183  //if(rpcRegion==1&&dfg>1.&&dr>100.){
184  if (debug)
185  std::cout << "\t \t \t CSC Station= " << CSCId.station() << " Ring= " << CSCId.ring()
186  << " Chamber= " << CSCId.chamber() << " cscphi=" << cscphi * 180 / 3.14159265
187  << "\t RPC Station= " << rpcId.station() << " ring= " << rpcId.ring() << " segment =-> "
188  << rpcsrv.segment() << " rollphi=" << rpcphi * 180 / 3.14159265 << "\t dfg=" << dfg
189  << " dz=" << diffz << " dr=" << dr << std::endl;
190  }
191  }
192 
193  float D = CenterRollinCSCFrame.z();
194 
195  float X = Xo + dx * D / dz;
196  float Y = Yo + dy * D / dz;
197  float Z = D;
198 
199  const TrapezoidalStripTopology* top_ =
200  dynamic_cast<const TrapezoidalStripTopology*>(&(rollasociated->topology()));
201  LocalPoint xmin = top_->localPosition(0.);
202  if (debug)
203  std::cout << "CSC \t \t \t xmin of this Roll " << xmin << "cm" << std::endl;
204  LocalPoint xmax = top_->localPosition((float)rollasociated->nstrips());
205  if (debug)
206  std::cout << "CSC \t \t \t xmax of this Roll " << xmax << "cm" << std::endl;
207  float rsize = fabs(xmax.x() - xmin.x());
208  if (debug)
209  std::cout << "CSC \t \t \t Roll Size " << rsize << "cm" << std::endl;
210  float stripl = top_->stripLength();
211  float stripw = top_->pitch();
212 
213  if (debug)
214  std::cout << "CSC \t \t \t Strip Lenght " << stripl << "cm" << std::endl;
215  if (debug)
216  std::cout << "CSC \t \t \t Strip Width " << stripw << "cm" << std::endl;
217 
218  if (debug)
219  std::cout << "CSC \t \t \t X Predicted in CSCLocal= " << X << "cm" << std::endl;
220  if (debug)
221  std::cout << "CSC \t \t \t Y Predicted in CSCLocal= " << Y << "cm" << std::endl;
222  if (debug)
223  std::cout << "CSC \t \t \t Z Predicted in CSCLocal= " << Z << "cm" << std::endl;
224 
225  float extrapolatedDistance = sqrt((X - Xo) * (X - Xo) + (Y - Yo) * (Y - Yo) + (Z - Zo) * (Z - Zo));
226 
227  if (debug)
228  std::cout << "CSC \t \t \t Is the distance of extrapolation less than MaxD? =" << extrapolatedDistance
229  << "cm"
230  << " MaxD=" << MaxD << "cm" << std::endl;
231 
232  if (extrapolatedDistance <= MaxD) {
233  if (debug)
234  std::cout << "CSC \t \t \t yes" << std::endl;
235 
236  GlobalPoint GlobalPointExtrapolated = TheChamber->toGlobal(LocalPoint(X, Y, Z));
237  if (debug)
238  std::cout << "CSC \t \t \t Point ExtraPolated in Global" << GlobalPointExtrapolated << std::endl;
239 
240  LocalPoint PointExtrapolatedRPCFrame = RPCSurface.toLocal(GlobalPointExtrapolated);
241 
242  if (debug)
243  std::cout << "CSC \t \t \t Point Extrapolated in RPCLocal" << PointExtrapolatedRPCFrame << std::endl;
244  if (debug)
245  std::cout << "CSC \t \t \t Corner of the Roll = (" << rsize * eyr << "," << stripl * eyr << ")"
246  << std::endl;
247  if (debug)
248  std::cout << "CSC \t \t \t Info About the Point Extrapolated in X Abs ("
249  << fabs(PointExtrapolatedRPCFrame.x()) << "," << fabs(PointExtrapolatedRPCFrame.y()) << ","
250  << fabs(PointExtrapolatedRPCFrame.z()) << ")" << std::endl;
251  if (debug)
252  std::cout << "CSC \t \t \t dz=" << fabs(PointExtrapolatedRPCFrame.z())
253  << " dx=" << fabs(PointExtrapolatedRPCFrame.x())
254  << " dy=" << fabs(PointExtrapolatedRPCFrame.y()) << std::endl;
255 
256  if (debug)
257  std::cout << "CSC \t \t \t Does the extrapolation go inside this roll????" << std::endl;
258 
259  if (fabs(PointExtrapolatedRPCFrame.z()) < 1. && fabs(PointExtrapolatedRPCFrame.x()) < rsize * eyr &&
260  fabs(PointExtrapolatedRPCFrame.y()) < stripl * eyr) {
261  if (debug)
262  std::cout << "CSC \t \t \t \t yes" << std::endl;
263  if (debug)
264  std::cout << "CSC \t \t \t \t Creating the RecHit" << std::endl;
265  RPCRecHit RPCPoint(rpcId, 0, PointExtrapolatedRPCFrame);
266  if (debug)
267  std::cout << "CSC \t \t \t \t Clearing the vector" << std::endl;
269  if (debug)
270  std::cout << "CSC \t \t \t \t Pushing back" << std::endl;
271  RPCPointVector.push_back(RPCPoint);
272  if (debug)
273  std::cout << "CSC \t \t \t \t Putting the vector" << std::endl;
275  }
276  }
277  }
278  }
279  }
280  }
281  }
282  }
283 }
int chamber() const
Definition: CSCDetId.h:62
Point3DBase< Scalar, LocalTag > LocalPoint
Definition: Definitions.h:30
LocalPoint localPosition(float strip) const override
T perp() const
Definition: PV3DBase.h:69
CSCDetId id() const
Get the (concrete) DetId.
Definition: CSCChamber.h:34
GlobalPoint toGlobal(const Local2DPoint &lp) const
Conversion to the global R.F. from the R.F. of the GeomDet.
Definition: GeomDet.h:49
int nstrips() const
Definition: RPCRoll.cc:24
T y() const
Definition: PV3DBase.h:60
#define X(str)
Definition: MuonsGrabber.cc:38
LocalPoint toLocal(const GlobalPoint &gp) const
Conversion to the R.F. of the GeomDet.
Definition: GeomDet.h:58
std::set< RPCDetId > const & getRolls(CSCStationIndex index) const
Definition: CSCObjectMap.cc:42
const Topology & topology() const override
Definition: RPCRoll.cc:18
const Plane & surface() const
The nominal surface of the GeomDet.
Definition: GeomDet.h:37
double MaxD
Definition: CSCSegtoRPC.h:23
iterator begin()
Definition: OwnVector.h:280
int endcap() const
Definition: CSCDetId.h:85
std::unique_ptr< RPCRecHitCollection > _ThePoints
Definition: CSCSegtoRPC.h:20
T barePhi() const
Definition: PV3DBase.h:65
C::const_iterator const_iterator
constant access iterator type
Definition: RangeMap.h:43
void push_back(D *&d)
Definition: OwnVector.h:326
RPCDetId id() const
Definition: RPCRoll.cc:16
int ring() const
Definition: RPCDetId.h:59
T sqrt(T t)
Definition: SSEVec.h:19
T z() const
Definition: PV3DBase.h:61
void clear()
Definition: OwnVector.h:481
float stripLength() const override
det heigth (strip length in the middle)
int ring() const
Definition: CSCDetId.h:68
iterator end()
Definition: OwnVector.h:285
#define debug
Definition: HDRShower.cc:19
DecomposeProduct< arg, typename Div::arg > D
Definition: Factorize.h:141
const CSCChamber * chamber(CSCDetId id) const
Return the chamber corresponding to given DetId.
Definition: CSCGeometry.cc:100
edm::OwnVector< RPCRecHit > RPCPointVector
Definition: CSCSegtoRPC.h:21
int station() const
Definition: CSCDetId.h:79
T x() const
Definition: PV3DBase.h:59
const RPCRoll * roll(RPCDetId id) const
Return a roll given its id.
Definition: RPCGeometry.cc:50
int station() const
Definition: RPCDetId.h:78
CSCSegtoRPC::~CSCSegtoRPC ( )

Definition at line 285 of file CSCSegtoRPC.cc.

285 {}

Member Function Documentation

std::unique_ptr<RPCRecHitCollection>&& CSCSegtoRPC::thePoints ( )
inline

Definition at line 17 of file CSCSegtoRPC.h.

References _ThePoints, and eostools::move().

17 { return std::move(_ThePoints); }
std::unique_ptr< RPCRecHitCollection > _ThePoints
Definition: CSCSegtoRPC.h:20
def move(src, dest)
Definition: eostools.py:511

Member Data Documentation

std::unique_ptr<RPCRecHitCollection> CSCSegtoRPC::_ThePoints
private

Definition at line 20 of file CSCSegtoRPC.h.

Referenced by CSCSegtoRPC(), and thePoints().

bool CSCSegtoRPC::inclcsc
private

Definition at line 22 of file CSCSegtoRPC.h.

double CSCSegtoRPC::MaxD
private

Definition at line 23 of file CSCSegtoRPC.h.

Referenced by CSCSegtoRPC().

edm::OwnVector<RPCRecHit> CSCSegtoRPC::RPCPointVector
private

Definition at line 21 of file CSCSegtoRPC.h.

Referenced by CSCSegtoRPC().