1 |
#ifndef L1RpcTriggerAnalysis_RPCDetIdUtil_H
|
2 |
#define L1RpcTriggerAnalysis_RPCDetIdUtil_H
|
3 |
|
4 |
#include "DataFormats/MuonDetId/interface/RPCDetId.h"
|
5 |
#include <iostream>
|
6 |
#include <ostream>
|
7 |
#include <cmath>
|
8 |
namespace edm { class EventSetup; }
|
9 |
|
10 |
class RPCDetIdUtil{
|
11 |
public:
|
12 |
RPCDetIdUtil( const RPCDetId & rpcDet) : theRpcDet(rpcDet) { }
|
13 |
RPCDetIdUtil( uint32_t rawId) : theRpcDet( RPCDetId(rawId) ) { }
|
14 |
|
15 |
bool isBarrel() const { return (theRpcDet.region()==0); }
|
16 |
|
17 |
unsigned int barrelLayer() const {
|
18 |
return theRpcDet.station() <=2 ?
|
19 |
2*( theRpcDet.station()-1)+ theRpcDet.layer()
|
20 |
: theRpcDet.station()+2;
|
21 |
}
|
22 |
unsigned int endcapLayer() const {
|
23 |
return theRpcDet.station();
|
24 |
}
|
25 |
unsigned int layer() const {
|
26 |
return isBarrel() ? barrelLayer() : endcapLayer();
|
27 |
}
|
28 |
|
29 |
//WARNING - use eta of DetUnit position, not muon direction
|
30 |
unsigned int layer(float eta) const {
|
31 |
if (fabs(eta) < 0.83) {
|
32 |
return barrelLayer();
|
33 |
} else if ( fabs(eta) < 0.93) {
|
34 |
if ( isBarrel() && (barrelLayer() < 6)) return barrelLayer();
|
35 |
} else if ( fabs(eta) < 1.04) {
|
36 |
if ( isBarrel() && (barrelLayer()==1)) return 1;
|
37 |
if ( isBarrel() && (barrelLayer()==2)) return 2;
|
38 |
if ( isBarrel() && (barrelLayer()==3)) return 3;
|
39 |
if ( isBarrel() && (barrelLayer()==4)) return 4;
|
40 |
// if ( isBarrel() && (barrelLayer()==5)) return 5;
|
41 |
if (!isBarrel() && endcapLayer()==1 ) return 5;
|
42 |
} else if ( fabs(eta)<1.14) {
|
43 |
if ( isBarrel() && (barrelLayer() < 3)) return barrelLayer();
|
44 |
if (!isBarrel() && endcapLayer()==1) return 3;
|
45 |
if (!isBarrel() && endcapLayer()==2) return 4;
|
46 |
} else if ( fabs(eta)<1.24) {
|
47 |
if ( isBarrel() && (barrelLayer() == 1)) return 1;
|
48 |
if (!isBarrel()) return endcapLayer();
|
49 |
} else return theRpcDet.station();
|
50 |
return 0;
|
51 |
}
|
52 |
|
53 |
int part() {
|
54 |
return isBarrel() ? theRpcDet.ring() :
|
55 |
(theRpcDet.region()==1 ? theRpcDet.ring()+1 : -theRpcDet.ring()-1);
|
56 |
}
|
57 |
|
58 |
RPCDetId rpdDetIt() { return theRpcDet; }
|
59 |
|
60 |
void print(const edm::EventSetup& es);
|
61 |
|
62 |
private:
|
63 |
RPCDetId theRpcDet;
|
64 |
friend std::ostream & operator<< (std::ostream &out, const RPCDetIdUtil &o);
|
65 |
};
|
66 |
#endif
|