test
CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
PrimitivesCombiner.cc
Go to the documentation of this file.
1 //Author: Giuseppe Codispoti
2 
4 
8 
11 
14 
16 
17 using namespace L1TwinMux;
18 
20  edm::ESHandle<DTGeometry> & muonGeom )
21  : _resol(res), _muonGeom(muonGeom),
22  _bx(-3), _radialAngle(4096), _bendingAngle(-520), _bendingResol(520),
23  _dtHI(0), _dtHO(0), _rpcIn(0), _rpcOut(0)
24 {}
25 
26 
27 
29 {
30  int qualityCode = dt.getDTData().qualityCode;
31  switch ( qualityCode ) {
32  case 2 : addDtHO( dt ); break;
33  case 3 : addDtHI( dt ); break;
34  default :
35  throw cms::Exception("Invalid DT Quality")
36  << "This module can combine only HI to HO (quality2/3), provided : "
37  << qualityCode << std::endl;
38  }
39 
40 }
41 
42 
44 {
45  if ( _dtHI )
46  throw cms::Exception("Invalid DT Quality")
47  << "DT primitive with quality HI already provided"
48  << std::endl;
49 
50  _dtHI = &prim;
51 }
52 
53 
55 {
56  if ( _dtHO )
57  throw cms::Exception("Invalid DT Quality")
58  << "DT primitive with quality HO already provided"
59  << std::endl;
60 
61  _dtHO = &prim;
62 }
63 
64 
66 {
67  _rpcIn = &prim;
68 }
69 
70 
72 {
73  _rpcOut = &prim;
74 }
75 
76 
77 
79 {
80  if ( !isValid() ) return;
81 
82  typedef PrimitiveCombiner::results localResult;
83  std::vector<localResult> localResults;
84 
85  _radialAngle = 0;
86  // inner and outer DT
87  if ( _dtHI && _dtHO ) {
88  localResults.push_back( combineDt( _dtHI, _dtHO ) );
89  _radialAngle = localResults.back().radialAngle;
90  }
91  // inner DT
92  else if ( _dtHI ) {
93  // if (!_dtHO) localResults.push_back(dummyCombineDt(_dtHI));
94  if ( _rpcIn ) {
95  localResults.push_back( combineDtRpc( _dtHI, _rpcIn ) );
97  }
98  if ( _rpcOut ) {
99  localResults.push_back( combineDtRpc( _dtHI, _rpcOut ) );
101  }
102  }
103  //outer DT
104  else if ( _dtHO ) {
105  // if (!_dtHI) localResults.push_back(dummyCombineDt(_dtHO));
106  if ( _rpcIn ) {
107  localResults.push_back( combineDtRpc( _dtHO, _rpcIn ) );
109  }
110  if ( _rpcOut ) {
111  localResults.push_back( combineDtRpc( _dtHO, _rpcOut ) );
113  }
114  }
115  // no DT
116  else if ( !_dtHI && !_dtHO ) {
117  if ( _rpcIn && _rpcOut ) {
118  results local = combineRpcRpc( _rpcIn, _rpcOut );
119  localResults.push_back( local );
120  _radialAngle = local.radialAngle;
121  //std::cout<<"Entered RPC-IN-OUT thing..."<<std::endl;
122  } else if ( _rpcIn ) {
123  //std::cout<<"Entered RPC-IN-ONLY thing..."<<std::endl;
125  _bendingAngle = -666;
126  return;
127  } else if ( _rpcOut ) {
128  //std::cout<<"Entered RPC-OUT-only thing..."<<std::endl;
130  _bendingAngle = -666;
131  return;
132  }
133  }
134  double weightSum = 0;
135  _bendingResol = 0;
136  _bendingAngle = 0;
137 
138  std::vector<localResult>::const_iterator it = localResults.begin();
139  std::vector<localResult>::const_iterator itend = localResults.end();
140  int kcount=0;
141  for ( ; it != itend; ++it ) {
142  //weightSum += it->bendingResol;
143  //_bendingAngle += it->bendingResol * it->bendingAngle;
144  kcount++;
145  //std::cout<<"combining result "<<kcount<<" with resolution "<<it->bendingResol<<std::endl;
146  weightSum += 1.0/(( it->bendingResol)*(it->bendingResol));
147  _bendingAngle += double(it->bendingAngle)/((it->bendingResol) * (it->bendingResol));
148  _bendingResol += it->bendingResol * it->bendingResol;
149  }
150 
151  _bendingAngle /= weightSum;
153 
154 }
155 
158 {
159 
160  // i want to combine also the DT data alone
161  results localResult;
162  localResult.radialAngle = dt->getDTData().radialAngle;
163  //std::cout<<" HEY!!! I am adding a DT benfing as a combination result! "<<std::endl;
164  localResult.bendingAngle=dt->getDTData().bendingAngle;
165  localResult.bendingResol=_resol.phibDtUnCorr;
166  return localResult;
167 }
168 
169 
170 
171 
174  const TriggerPrimitive * dt2 )
175 {
176 
177  const DTChamber* chamb1 = _muonGeom->chamber( dt1->detId<DTChamberId>() );
178  LocalPoint point1 = chamb1->toLocal( dt1->getCMSGlobalPoint() );
179 
180  const DTChamber* chamb2 = _muonGeom->chamber( dt2->detId<DTChamberId>() );
181  LocalPoint point2 = chamb2->toLocal( dt2->getCMSGlobalPoint() );
182 
183  results localResult;
184  localResult.radialAngle = 0.5 * ( dt1->getDTData().radialAngle + dt2->getDTData().radialAngle );
185 
190  if ( ( dt1->getDTData().wheel > 0 ) ||
191  ( ( dt1->getDTData().wheel == 0 ) &&
192  !( dt1->getDTData().sector == 0 || dt1->getDTData().sector == 3
193  || dt1->getDTData().sector == 4 || dt1->getDTData().sector == 7
194  || dt1->getDTData().sector == 8 || dt1->getDTData().sector == 11 ) )
195  ) {
197  localResult.bendingAngle = ( atan ( phiBCombined( point1.x(), point1.z(),
198  point2.x(), point2.z() )
199  )
200  - ( localResult.radialAngle/4096.0 )
201  ) * 512;
202  } else {
203  // negative chambers
204  localResult.bendingAngle = ( atan ( -phiBCombined( point1.x(), point1.z(),
205  point2.x(), point2.z() )
206  )
207  - ( localResult.radialAngle/4096.0)
208  ) * 512;
209  }
211  point1.z(), point2.z() );
212 
213  //std::cout<<" == === COMBINING DT-DT === == "<<std::endl;
214  //std::cout << "dt-dt radial : " << dt1->getDTData().radialAngle << " * " << dt2->getDTData().radialAngle << " = " << localResult.radialAngle << '\n';
215  //std::cout << " " << point1.x() << " " << point1.z() << " " << dt1->getDTData().qualityCode << '\n';
216  //std::cout << " " << point2.x() << " " << point2.z() << " " << dt2->getDTData().qualityCode << '\n';
217  //std::cout << "dt-dt bending : " << dt1->getDTData().bendingAngle << " * " << dt2->getDTData().bendingAngle << " = "
218  // << localResult.bendingAngle << '\n';
219  //std::cout<<" --- this was sector "<<dt1->getDTData().sector<<" and wheel "<<dt1->getDTData().wheel<<std::endl;
220 
221  return localResult;
222 
223 }
224 
227  const TriggerPrimitive * rpc )
228 {
229 
230  results localResult;
231  localResult.radialAngle = dt->getDTData().radialAngle;
232 
233  const DTChamber* chamb1 = _muonGeom->chamber( dt->detId<DTChamberId>() );
234  LocalPoint point1 = chamb1->toLocal( dt->getCMSGlobalPoint() );
235  int station = rpc->detId<RPCDetId>().station();
236  int sector = rpc->detId<RPCDetId>().sector();
237  int wheel = rpc->detId<RPCDetId>().ring();
238  const DTChamber* chamb2 = _muonGeom->chamber( DTChamberId( wheel, station, sector ) );
239  LocalPoint point2 = chamb2->toLocal( rpc->getCMSGlobalPoint() );
240 
241  if ( ( dt->getDTData().wheel > 0 ) ||
242  ( ( dt->getDTData().wheel == 0 ) &&
243  !( dt->getDTData().sector == 0 || dt->getDTData().sector==3
244  || dt->getDTData().sector==4 || dt->getDTData().sector==7
245  || dt->getDTData().sector==8 || dt->getDTData().sector==11 ) )
246  ) {
247  // positive wheels
248  localResult.bendingAngle = ( atan( phiBCombined( point1.x(), point1.z(),
249  point2.x(), point2.z() )
250  )
251  - ( localResult.radialAngle/4096.0 )
252  ) * 512;
253  } else {
254  // negative wheels
255  localResult.bendingAngle = ( atan( -phiBCombined( point1.x(), point1.z(),
256  point2.x(), point2.z() )
257  )
258  - ( localResult.radialAngle/4096.0 )
259  ) * 512;
260  }
262  point1.z(), point2.z() );
263 
264  return localResult;
265 
266 }
267 
268 
269 // dt+rpc solo bending, phi dt
270 // dt+dt bending, media della posizione, direzione in base alla differenza dei due punti
271 // cancellare seconda traccia (bx diverso)
272 
273 int
275 {
276  int radialAngle = 0;
277  int radialAngle2 = 0;
278  int sector = rpc->detId<RPCDetId>().sector();
279  float phiGlobal = rpc->getCMSGlobalPhi();
280  // int wheel = rpc->detId<RPCDetId>().ring();
281  // from phiGlobal to radialAngle of the primitive in sector sec in [1..12]
282  if ( sector == 1) radialAngle = int( phiGlobal*4096 );
283  else {
284  if ( phiGlobal >= 0) radialAngle = int( (phiGlobal-(sector-1)*Geom::pi()/6)*4096 );
285  else radialAngle = int( (phiGlobal+(13-sector)*Geom::pi()/6)*4096 );
286  }
287  //if ( ( wheel>0 ) ||
288  // ( ( wheel==0 ) &&
289  // ( sector==0 || sector==3 || sector==4 || sector==7 || sector==8 || sector==11 ) ) )
290  radialAngle2 = radialAngle;
291  //else
292  // radialAngle2 = -radialAngle;
293  return radialAngle2;
294 }
295 
298  const TriggerPrimitive * rpc2 )
299 {
300  int station = rpc1->detId<RPCDetId>().station();
301  int sector = rpc1->detId<RPCDetId>().sector();
302  int wheel = rpc1->detId<RPCDetId>().ring();
303  const DTChamber* chamb1 = _muonGeom->chamber( DTChamberId( wheel, station, sector ) );
304  LocalPoint point1 = chamb1->toLocal( rpc1->getCMSGlobalPoint() );
305 
306 
307  station = rpc2->detId<RPCDetId>().station();
308  sector = rpc2->detId<RPCDetId>().sector();
309  wheel = rpc2->detId<RPCDetId>().ring();
310  const DTChamber* chamb2 = _muonGeom->chamber( DTChamberId( wheel, station, sector ) );
311  LocalPoint point2 = chamb2->toLocal( rpc2->getCMSGlobalPoint() );
312 
313 
314  results localResult;
315  localResult.radialAngle = 0.5*(radialAngleFromGlobalPhi( rpc1 )+radialAngleFromGlobalPhi( rpc2 )) ;
316 
317  if ( ( wheel>0 ) ||
318  ( ( wheel==0 ) &&
319  !( sector==0 || sector==3 || sector==4 || sector==7 || sector==8 || sector==11 ) ) )
320  localResult.bendingAngle = ( atan ( phiBCombined( point1.x(),
321  point1.z(),
322  point2.x(),
323  point2.z() )
324  - ( localResult.radialAngle / 4096.0 )
325  ) ) * 512;
326  else
327  localResult.bendingAngle = ( atan (-phiBCombined( point1.x(),
328  point1.z(),
329  point2.x(),
330  point2.z() )
331  - ( localResult.radialAngle/4096.0 )
332  ) ) * 512;
333  localResult.bendingResol = phiBCombinedResol( _resol.xRpc, _resol.xRpc, point1.z(), point2.z());
334 
335 
336  return localResult;
337 
338 }
float dt
Definition: AMPTWrapper.h:126
const TriggerPrimitive * _rpcOut
const DTData getDTData() const
void addRpcIn(const TriggerPrimitive &prim)
a struct useful for resulution info sharing
bool isValid() const
valid if we have at least: 1 rpc; 1 dt + 1 any
LocalPoint toLocal(const GlobalPoint &gp) const
Conversion to the R.F. of the GeomDet.
Definition: GeomDet.h:69
void combine()
do combine the primitives
void addDtHI(const TriggerPrimitive &prim)
const TriggerPrimitive * _dtHI
const double getCMSGlobalPhi() const
float phiBCombined(const float &xDt, const float &zDt, const float &xRpc, const float &zRpc)
FIXME : Calculates new phiBending, check how to use.
const TriggerPrimitive * _rpcIn
a struct for internal usage: store results
T sqrt(T t)
Definition: SSEVec.h:18
void addDtHO(const TriggerPrimitive &prim)
T z() const
Definition: PV3DBase.h:64
results combineDtRpc(const TriggerPrimitive *dt, const TriggerPrimitive *rpc)
Calculates new phiBending, check how to use weights.
results combineRpcRpc(const TriggerPrimitive *rpc1, const TriggerPrimitive *rpc2)
Calculates new phiBending, check how to use weights.
int radialAngleFromGlobalPhi(const TriggerPrimitive *rpc)
void addRpcOut(const TriggerPrimitive &prim)
const GlobalPoint getCMSGlobalPoint() const
PrimitiveCombiner(const resolutions &res, edm::ESHandle< DTGeometry > &muonGeom)
float phiBCombinedResol(const float &resol_xDt, const float &resol_xRpc, const float &zDt, const float &zRpc)
FIXME END.
void addDt(const TriggerPrimitive &prim)
feed the combiner with the available primitives
const TriggerPrimitive * _dtHO
constexpr double pi()
Definition: Pi.h:31
results dummyCombineDt(const TriggerPrimitive *dt)
T x() const
Definition: PV3DBase.h:62
results combineDt(const TriggerPrimitive *dt, const TriggerPrimitive *rpc)
Calculates new phiBending, check how to use weights.
edm::ESHandle< DTGeometry > _muonGeom