8 |
|
#include "UserCode/L1RpcTriggerAnalysis/interface/DTphDigiSpec.h" |
9 |
|
#include "UserCode/L1RpcTriggerAnalysis/interface/CSCDigiSpec.h" |
10 |
|
#include "UserCode/L1RpcTriggerAnalysis/interface/RPCDigiSpec.h" |
11 |
+ |
#include "DataFormats/MuonDetId/interface/MuonSubdetId.h" |
12 |
|
|
13 |
|
#include "UserCode/L1RpcTriggerAnalysis/interface/Pattern.h" |
14 |
|
#include "UserCode/L1RpcTriggerAnalysis/interface/GoldenPattern.h" |
37 |
|
PatternManager::~PatternManager() |
38 |
|
{ |
39 |
|
std::cout <<" Events checked for pattenrs: " << theEvForPatCounter << std::endl; |
40 |
< |
std::cout <<" Events used for pattenrs: " << theEvForPatCounter << std::endl; |
40 |
> |
std::cout <<" Events used for pattenrs: " << theEvUsePatCounter << std::endl; |
41 |
|
std::cout <<" Size of GoldenPatterns: " << theGPs.size() << std::endl; |
42 |
|
if (theConfig.getUntrackedParameter<bool>("dump",false)) { |
43 |
|
for (std::map< GoldenPattern::Key, GoldenPattern>::const_iterator |
50 |
|
|
51 |
|
void PatternManager::run(const EventObj* ev, const TrackObj * simu, const HitSpecObj * hitSpec, const VDigiSpec & vDigi) |
52 |
|
{ |
53 |
+ |
|
54 |
+ |
|
55 |
|
if (!hitSpec) return; |
56 |
|
if (hitSpec->rawId() == 0 ) return; |
57 |
|
double phiref = hitSpec->position().phi(); |
76 |
|
bool isOK = pattern.add(*is); |
77 |
|
if (!isOK) return; |
78 |
|
} |
79 |
+ |
|
80 |
|
if (pattern.size() == 0) return; |
81 |
|
theEvUsePatCounter++; |
82 |
|
|
88 |
|
L1Obj PatternManager::check(const EventObj* ev, const TrackObj * simu, const HitSpecObj * hitSpec, const VDigiSpec & vDigi) |
89 |
|
{ |
90 |
|
L1Obj candidate; |
91 |
+ |
|
92 |
|
if (!hitSpec) return candidate; |
88 |
– |
/* |
93 |
|
if (hitSpec->rawId() == 0 ) return candidate; |
94 |
|
double phiref = hitSpec->position().phi(); |
95 |
|
double ptref = simu->pt(); |
96 |
|
int chargeref = simu->charge(); |
97 |
|
unsigned int detref = hitSpec->rawId(); |
98 |
< |
if (detref != 637602109 && detref != 637634877 && |
98 |
> |
/* |
99 |
> |
if (detref != 637602109 && detref != 637634877 && |
100 |
|
detref != 637599914 && detref != 637632682 ) return candidate; |
101 |
|
|
102 |
|
bool precisePos = ( fabs(hitSpec->position().phi()-1.025) < 0.001); |
103 |
|
if (!precisePos) return candidate; |
104 |
|
if ( simu->pt() < 26. || simu->pt() > 27. ) return candidate; |
105 |
|
|
101 |
– |
std::cout <<" ------------------ EVENT: " << std::endl; |
106 |
|
*/ |
107 |
< |
Pattern pattern; |
107 |
> |
// std::cout <<" ------------------ EVENT: "<<*ev <<" number of digis: "<<vDigi.size()<< std::endl; |
108 |
> |
std::vector<Pattern> vpattern(1); |
109 |
|
theEvForPatCounter++; |
110 |
+ |
static bool skipRpcData = theConfig.getUntrackedParameter<bool>("skipRpcData", false); |
111 |
+ |
static bool skipDtCscData = theConfig.getUntrackedParameter<bool>("skipDtCscData",false); |
112 |
|
for (VDigiSpec::const_iterator is= vDigi.begin(); is!=vDigi.end(); is++) { |
113 |
< |
bool isOK = pattern.add(*is); |
114 |
< |
if (!isOK) { return candidate; } |
113 |
> |
DetId detId( is->first); |
114 |
> |
if (skipRpcData && detId.subdetId()==MuonSubdetId::RPC) continue; |
115 |
> |
if (skipDtCscData && (detId.subdetId()==MuonSubdetId::DT || detId.subdetId()==MuonSubdetId::CSC) ) continue; |
116 |
> |
//std::cout << "adding------- "<< is-vDigi.begin()+1 <<" digi det: "<<is->first<<"(rpc:"<<(detId.subdetId()==MuonSubdetId::RPC)<<") data: "<<is->second<< std::endl; |
117 |
> |
Pattern::add(vpattern,*is); |
118 |
> |
//std::cout <<" after vpattern has size: "<<vpattern.size() << std::endl; |
119 |
> |
if (vpattern.size() > 100) break; |
120 |
|
} |
121 |
< |
if (pattern.size() == 0) return candidate; |
122 |
< |
// std::cout <<" ------------------ END EVENT, COMPARE" << std::endl; |
121 |
> |
if (vpattern[0].size() == 0) return candidate; |
122 |
> |
//std::cout <<" ------------------ END EVENT, NOW COMPARE, has #patterns: "<<vpattern.size()<<" vpattern[0].size="<<vpattern[0].size() << std::endl; |
123 |
|
|
124 |
< |
// GoldenPattern::Key thisKey(detref, ptref, chargeref, phiref ); |
125 |
< |
// std::cout << thisKey << std::endl; |
124 |
> |
GoldenPattern::Key thisKey(detref, ptref, chargeref, phiref ); |
125 |
> |
//std::cout << thisKey << std::endl; |
126 |
|
|
127 |
|
GoldenPattern::Result bestMatching; |
128 |
|
GoldenPattern::Key bestKey; |
129 |
< |
for (std::map< GoldenPattern::Key, GoldenPattern>::iterator igps = theGPs.begin(); igps != theGPs.end(); igps++) { |
129 |
> |
for (auto ip=vpattern.begin(); ip!= vpattern.end();++ip) { |
130 |
> |
const Pattern & pattern = *ip; |
131 |
> |
//std::cout << " HAS PATTERN "<<pattern << std::endl; |
132 |
> |
for (auto igps = theGPs.begin(); igps != theGPs.end(); ++igps) { |
133 |
|
// if (!(thisKey==igps->first)) continue; |
119 |
– |
// std::cout << " HAS PATTERN "<<pattern << std::endl; |
134 |
|
GoldenPattern & gp = igps->second; |
135 |
|
GoldenPattern::Result result = gp.compare(pattern); |
136 |
< |
if (!result.hasRpcDet(637602109) && !result.hasRpcDet(637634877) && !result.hasRpcDet(637599914) && !result.hasRpcDet(637632682)) continue; |
137 |
< |
if (result > bestMatching) { |
136 |
> |
// if (!result.hasRpcDet(637602109) && !result.hasRpcDet(637634877) && !result.hasRpcDet(637599914) && !result.hasRpcDet(637632682)) continue; |
137 |
> |
// if (!result.hasRpcDet(igps->first.theDet)) continue; |
138 |
> |
// if (result.nMatchedTot() < 5 )continue; |
139 |
> |
// if (!result) continue; |
140 |
> |
//std::cout <<"PATT KEY: "<<igps->first<<" "<<result ; //<<std::endl; |
141 |
> |
if (bestMatching < result) { |
142 |
|
bestMatching = result; |
143 |
|
bestKey = igps->first; |
144 |
< |
} |
145 |
< |
// std::cout <<result << std::endl; |
144 |
> |
//std::cout <<" ----"<<" pt: "<< bestKey.ptValue()<<std::endl; |
145 |
> |
} |
146 |
> |
//else std::cout <<std::endl; |
147 |
|
} |
148 |
< |
// std::cout <<" ------------------ END COMPARE: " << std::endl; |
149 |
< |
// std::cout <<"BEST: "<< bestMatching<<" pt: "<<bestKey.ptValue()<<std::endl; |
148 |
> |
} |
149 |
> |
|
150 |
> |
//std::cout <<" ------------------ END COMPARE: " << std::endl; |
151 |
> |
//std::cout <<"BEST KEY: "<<bestKey<<" "<< bestMatching<<std::cout <<" ######"<<" pt: "<< bestKey.ptValue()<<std::endl; |
152 |
> |
// abort(); |
153 |
|
if (bestMatching) { |
154 |
|
candidate.pt = bestKey.ptValue(); |
155 |
|
candidate.eta = 1.; |