ViewVC Help
View File | Revision Log | Show Annotations | Root Listing
root/cvsroot/UserCode/L1RpcTriggerAnalysis/interface/GoldenPattern.h
Revision: 1.6
Committed: Fri Jun 28 08:31:12 2013 UTC (11 years, 10 months ago) by akalinow
Content type: text/plain
Branch: MAIN
CVS Tags: Artur_28_06_2013
Changes since 1.5: +14 -21 lines
Log Message:
*updates by AK

File Contents

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