1 |
konec |
1.1 |
#ifndef UserCode_L1RpcTriggerAnalysis_GoldenPattern_H
|
2 |
|
|
#define UserCode_L1RpcTriggerAnalysis_GoldenPattern_H
|
3 |
|
|
|
4 |
|
|
#include "UserCode/L1RpcTriggerAnalysis/interface/L1RpcTriggerAnalysisEfficiencyUtilities.h"
|
5 |
|
|
#include "UserCode/L1RpcTriggerAnalysis/interface/Pattern.h"
|
6 |
|
|
#include <map>
|
7 |
|
|
#include <vector>
|
8 |
|
|
#include <cmath>
|
9 |
|
|
#include <ostream>
|
10 |
|
|
#include <iostream>
|
11 |
|
|
|
12 |
|
|
class GoldenPattern {
|
13 |
|
|
public:
|
14 |
|
|
|
15 |
|
|
//
|
16 |
|
|
// where
|
17 |
|
|
//
|
18 |
akalinow |
1.5 |
enum PosBenCase { POSRPC=0, POSCSC=1, BENCSC=2, POSDT=3, BENDT=4 };
|
19 |
konec |
1.1 |
|
20 |
|
|
//
|
21 |
|
|
// Key
|
22 |
|
|
//
|
23 |
|
|
struct Key {
|
24 |
|
|
Key(uint32_t det=0, double pt=0, int charge= 0, double phi=0) : theDet(det), theCharge(charge) {
|
25 |
|
|
thePtCode = L1RpcTriggerAnalysisEfficiencyUtilities::PtScale().ptCode(pt);
|
26 |
|
|
while (phi < 0) { phi+=2*M_PI; }
|
27 |
|
|
thePhiCode = int( phi * 3000.);
|
28 |
|
|
}
|
29 |
akalinow |
1.5 |
inline bool operator< (const Key & o) const {
|
30 |
konec |
1.1 |
if (theCharge*thePtCode < o.theCharge*o.thePtCode) return true;
|
31 |
|
|
else if (theCharge*thePtCode==o.theCharge*o.thePtCode && thePhiCode < o.thePhiCode) return true;
|
32 |
|
|
else if (theCharge*thePtCode==o.theCharge*o.thePtCode && thePhiCode==o.thePhiCode && theDet<o.theDet) return true;
|
33 |
|
|
else return false;
|
34 |
|
|
}
|
35 |
|
|
bool operator==(const Key& o) const {
|
36 |
akalinow |
1.4 |
return !(theDet!=o.theDet || thePtCode!=o.thePtCode || thePhiCode!=o.thePhiCode || theCharge!=o.theCharge);
|
37 |
konec |
1.1 |
}
|
38 |
|
|
double ptValue() const { return L1RpcTriggerAnalysisEfficiencyUtilities::PtScale().ptValue( thePtCode); }
|
39 |
|
|
double phiValue() const { return (double)thePhiCode/3000.; }
|
40 |
akalinow |
1.5 |
double etaValue() const { return 6*(theDet==637602109) +
|
41 |
|
|
7*(theDet==637634877) +
|
42 |
|
|
8*(theDet==637599914) +
|
43 |
|
|
9*(theDet==637632682); }
|
44 |
konec |
1.1 |
uint32_t theDet;
|
45 |
|
|
unsigned int thePtCode;
|
46 |
|
|
unsigned int thePhiCode;
|
47 |
|
|
int theCharge;
|
48 |
|
|
friend std::ostream & operator << (std::ostream &out, const Key & o) {
|
49 |
|
|
out << "Key_det:"<<o.theDet<<"_pt:"<<o.thePtCode<<"_charge"<<o.theCharge<<"_phi:"<<o.thePhiCode;
|
50 |
|
|
return out;
|
51 |
|
|
}
|
52 |
|
|
};
|
53 |
|
|
|
54 |
|
|
//
|
55 |
|
|
// Result
|
56 |
|
|
//
|
57 |
|
|
class Result {
|
58 |
|
|
public:
|
59 |
akalinow |
1.5 |
Result() : checkMe(true), theValue(0.),
|
60 |
|
|
hasStation1(false), hasStation2(false) {
|
61 |
|
|
nMatchedPoints[GoldenPattern::POSRPC] = 0;
|
62 |
|
|
nMatchedPoints[GoldenPattern::POSDT] = 0;
|
63 |
|
|
nMatchedPoints[GoldenPattern::POSCSC] = 0;
|
64 |
|
|
nMatchedPoints[GoldenPattern::BENDT] = 0;
|
65 |
|
|
nMatchedPoints[GoldenPattern::BENCSC] = 0;
|
66 |
|
|
}
|
67 |
konec |
1.1 |
bool operator<( const Result & o) const;
|
68 |
|
|
operator bool() const;
|
69 |
|
|
double value() const;
|
70 |
|
|
unsigned int nMatchedTot() const;
|
71 |
konec |
1.2 |
bool hasRpcDet(uint32_t rawId) {
|
72 |
akalinow |
1.5 |
for (auto it=myResults[GoldenPattern::POSRPC].cbegin();
|
73 |
|
|
it != myResults[GoldenPattern::POSRPC].cend(); ++it) {
|
74 |
konec |
1.2 |
if (it->first == rawId && it->second > 0. && it->second < 1.) return true;
|
75 |
|
|
}
|
76 |
|
|
return false;
|
77 |
|
|
}
|
78 |
konec |
1.1 |
private:
|
79 |
|
|
void run() const { if (checkMe) {checkMe=false; runNoCheck(); } }
|
80 |
|
|
void runNoCheck() const;
|
81 |
|
|
double norm(PosBenCase where, double whereInDist) const;
|
82 |
|
|
private:
|
83 |
|
|
mutable bool checkMe;
|
84 |
|
|
mutable double theValue;
|
85 |
akalinow |
1.5 |
//mutable unsigned int nMatchedPosRpc, nMatchedPosCsc, nMatchedPosDt, nMatchedBenCsc, nMatchedBenDt;
|
86 |
|
|
mutable std::map<GoldenPattern::PosBenCase, unsigned int> nMatchedPoints;
|
87 |
|
|
|
88 |
konec |
1.3 |
bool hasStation1, hasStation2;
|
89 |
akalinow |
1.5 |
mutable std::map<GoldenPattern::PosBenCase, std::vector< std::pair<uint32_t, double > > > myResults;
|
90 |
|
|
/*
|
91 |
konec |
1.1 |
std::vector< std::pair<uint32_t, double > > posRpcResult;
|
92 |
|
|
std::vector< std::pair<uint32_t, double > > posCscResult;
|
93 |
|
|
std::vector< std::pair<uint32_t, double > > benCscResult;
|
94 |
|
|
std::vector< std::pair<uint32_t, double > > posDtResult;
|
95 |
|
|
std::vector< std::pair<uint32_t, double > > benDtResult;
|
96 |
akalinow |
1.5 |
*/
|
97 |
konec |
1.1 |
friend std::ostream & operator << (std::ostream &out, const Result& o);
|
98 |
|
|
friend class GoldenPattern;
|
99 |
|
|
};
|
100 |
|
|
|
101 |
|
|
|
102 |
|
|
//
|
103 |
|
|
// GoldenPatterns methods
|
104 |
|
|
//
|
105 |
|
|
GoldenPattern() {}
|
106 |
|
|
GoldenPattern(const GoldenPattern::Key & key) : theKey(key) {}
|
107 |
|
|
void add( const Pattern & p);
|
108 |
|
|
void add( GoldenPattern::PosBenCase aCase, uint32_t rawId, int pos, unsigned int freq);
|
109 |
|
|
Result compare( const Pattern & p) const;
|
110 |
|
|
|
111 |
|
|
private:
|
112 |
|
|
|
113 |
akalinow |
1.5 |
///Pattern kinematical identification (eta,phi,pt)
|
114 |
konec |
1.1 |
Key theKey;
|
115 |
akalinow |
1.5 |
|
116 |
|
|
///Distribution in given DetUnit.
|
117 |
konec |
1.1 |
typedef std::map<int, unsigned int> MFreq;
|
118 |
akalinow |
1.5 |
|
119 |
|
|
///Ditribution in DetUnits. For given measuremnt type, one can have
|
120 |
|
|
///measurementd in many layers(=DetUnits)
|
121 |
konec |
1.1 |
typedef std::map<uint32_t, MFreq > DetFreq;
|
122 |
akalinow |
1.5 |
|
123 |
|
|
///Set of distributions for all measurement types (DT position, DT bending, RPC, etc)
|
124 |
|
|
typedef std::map<GoldenPattern::PosBenCase, DetFreq > SystFreq;
|
125 |
konec |
1.1 |
|
126 |
akalinow |
1.5 |
SystFreq PattCore;
|
127 |
konec |
1.1 |
|
128 |
|
|
private:
|
129 |
|
|
|
130 |
|
|
void purge();
|
131 |
|
|
double whereInDistribution(int obj, const MFreq & m) const;
|
132 |
|
|
friend std::ostream & operator << (std::ostream &out, const GoldenPattern & o);
|
133 |
|
|
friend class PatternManager;
|
134 |
|
|
};
|
135 |
|
|
#endif
|