50 |
|
|
51 |
|
void PatternManager::run(const EventObj* ev, const TrackObj * simu, const HitSpecObj * hitSpec, const VDigiSpec & vDigi) |
52 |
|
{ |
53 |
– |
|
54 |
– |
|
53 |
|
if (!hitSpec) return; |
54 |
|
if (hitSpec->rawId() == 0 ) return; |
55 |
|
double phiref = hitSpec->position().phi(); |
70 |
|
|
71 |
|
Pattern pattern; |
72 |
|
theEvForPatCounter++; |
73 |
< |
for (VDigiSpec::const_iterator is= vDigi.begin(); is!=vDigi.end(); is++) { |
73 |
> |
for (VDigiSpec::const_iterator is= vDigi.begin(); is!=vDigi.end(); ++is) { |
74 |
|
bool isOK = pattern.add(*is); |
75 |
|
if (!isOK) return; |
76 |
|
} |
79 |
– |
|
77 |
|
if (pattern.size() == 0) return; |
78 |
|
theEvUsePatCounter++; |
79 |
|
|
85 |
|
L1Obj PatternManager::check(const EventObj* ev, const TrackObj * simu, const HitSpecObj * hitSpec, const VDigiSpec & vDigi) |
86 |
|
{ |
87 |
|
L1Obj candidate; |
91 |
– |
|
88 |
|
if (!hitSpec) return candidate; |
89 |
|
if (hitSpec->rawId() == 0 ) return candidate; |
90 |
|
double phiref = hitSpec->position().phi(); |
92 |
|
int chargeref = simu->charge(); |
93 |
|
unsigned int detref = hitSpec->rawId(); |
94 |
|
/* |
95 |
< |
if (detref != 637602109 && detref != 637634877 && |
95 |
> |
if (detref != 637602109 && detref != 637634877 && |
96 |
|
detref != 637599914 && detref != 637632682 ) return candidate; |
97 |
|
|
98 |
|
bool precisePos = ( fabs(hitSpec->position().phi()-1.025) < 0.001); |
105 |
|
theEvForPatCounter++; |
106 |
|
static bool skipRpcData = theConfig.getUntrackedParameter<bool>("skipRpcData", false); |
107 |
|
static bool skipDtCscData = theConfig.getUntrackedParameter<bool>("skipDtCscData",false); |
108 |
< |
for (VDigiSpec::const_iterator is= vDigi.begin(); is!=vDigi.end(); is++) { |
108 |
> |
for (VDigiSpec::const_iterator is= vDigi.begin(); is!=vDigi.end(); ++is) { |
109 |
|
DetId detId( is->first); |
110 |
|
if (skipRpcData && detId.subdetId()==MuonSubdetId::RPC) continue; |
111 |
|
if (skipDtCscData && (detId.subdetId()==MuonSubdetId::DT || detId.subdetId()==MuonSubdetId::CSC) ) continue; |
112 |
< |
//std::cout << "adding------- "<< is-vDigi.begin()+1 <<" digi det: "<<is->first<<"(rpc:"<<(detId.subdetId()==MuonSubdetId::RPC)<<") data: "<<is->second<< std::endl; |
112 |
> |
if(detId.subdetId()==MuonSubdetId::DT && DTphDigiSpec(is->first, is->second).bxNum()!=0) continue; //AK. Correct? |
113 |
> |
// std::cout << "adding------- "<< is-vDigi.begin()+1 <<" digi det: "<<is->first<<"(rpc:"<<(detId.subdetId()==MuonSubdetId::RPC)<<") data: "<<is->second<< std::endl; |
114 |
|
Pattern::add(vpattern,*is); |
115 |
< |
//std::cout <<" after vpattern has size: "<<vpattern.size() << std::endl; |
115 |
> |
// std::cout <<" after vpattern has size: "<<vpattern.size() << std::endl; |
116 |
|
if (vpattern.size() > 100) break; |
117 |
|
} |
118 |
|
if (vpattern[0].size() == 0) return candidate; |
119 |
|
//std::cout <<" ------------------ END EVENT, NOW COMPARE, has #patterns: "<<vpattern.size()<<" vpattern[0].size="<<vpattern[0].size() << std::endl; |
120 |
|
|
121 |
|
GoldenPattern::Key thisKey(detref, ptref, chargeref, phiref ); |
122 |
< |
//std::cout << thisKey << std::endl; |
122 |
> |
// std::cout << thisKey << std::endl; |
123 |
|
|
124 |
|
GoldenPattern::Result bestMatching; |
125 |
|
GoldenPattern::Key bestKey; |
126 |
< |
for (auto ip=vpattern.begin(); ip!= vpattern.end();++ip) { |
127 |
< |
const Pattern & pattern = *ip; |
128 |
< |
//std::cout << " HAS PATTERN "<<pattern << std::endl; |
129 |
< |
for (auto igps = theGPs.begin(); igps != theGPs.end(); ++igps) { |
130 |
< |
// if (!(thisKey==igps->first)) continue; |
131 |
< |
GoldenPattern & gp = igps->second; |
132 |
< |
GoldenPattern::Result result = gp.compare(pattern); |
133 |
< |
// if (!result.hasRpcDet(637602109) && !result.hasRpcDet(637634877) && !result.hasRpcDet(637599914) && !result.hasRpcDet(637632682)) continue; |
134 |
< |
// if (!result.hasRpcDet(igps->first.theDet)) continue; |
135 |
< |
// if (result.nMatchedTot() < 5 )continue; |
136 |
< |
// if (!result) continue; |
137 |
< |
//std::cout <<"PATT KEY: "<<igps->first<<" "<<result ; //<<std::endl; |
138 |
< |
if (bestMatching < result) { |
139 |
< |
bestMatching = result; |
140 |
< |
bestKey = igps->first; |
141 |
< |
//std::cout <<" ----"<<" pt: "<< bestKey.ptValue()<<std::endl; |
142 |
< |
} |
143 |
< |
//else std::cout <<std::endl; |
144 |
< |
} |
126 |
> |
for (auto ip=vpattern.cbegin(); ip!= vpattern.cend();++ip) { |
127 |
> |
const Pattern & pattern = *ip; |
128 |
> |
// std::cout << " HAS PATTERN "<<pattern << std::endl; |
129 |
> |
for (std::map< GoldenPattern::Key, GoldenPattern>::iterator igps = theGPs.begin(); igps != theGPs.end(); ++igps) { |
130 |
> |
// if (!(thisKey==igps->first)) continue; |
131 |
> |
GoldenPattern & gp = igps->second; |
132 |
> |
GoldenPattern::Result result = gp.compare(pattern); |
133 |
> |
// if (!result.hasRpcDet(637602109) && !result.hasRpcDet(637634877) && !result.hasRpcDet(637599914) && !result.hasRpcDet(637632682)) continue; |
134 |
> |
// if (!result.hasRpcDet(igps->first.theDet)) continue; |
135 |
> |
// if (result.nMatchedTot() < 5 )continue; |
136 |
> |
// if (!result) continue; |
137 |
> |
// std::cout <<"PATT KEY: "<<igps->first<<" "<<result ; //<<std::endl; |
138 |
> |
if (bestMatching < result) { |
139 |
> |
bestMatching = result; |
140 |
> |
bestKey = igps->first; |
141 |
> |
// std::cout <<" ----"<<" pt: "<< bestKey.ptValue()<<std::endl; |
142 |
> |
} |
143 |
> |
//else std::cout <<std::endl; |
144 |
> |
} |
145 |
|
} |
146 |
|
|
147 |
< |
//std::cout <<" ------------------ END COMPARE: " << std::endl; |
148 |
< |
//std::cout <<"BEST KEY: "<<bestKey<<" "<< bestMatching<<std::cout <<" ######"<<" pt: "<< bestKey.ptValue()<<std::endl; |
147 |
> |
// std::cout <<" ------------------ END COMPARE: " << std::endl; |
148 |
> |
// std::cout <<"BEST KEY: "<<bestKey<<" "<< bestMatching<<std::cout <<" ######"<<" pt: "<< bestKey.ptValue()<<std::endl; |
149 |
|
// abort(); |
150 |
|
if (bestMatching) { |
151 |
|
candidate.pt = bestKey.ptValue(); |
152 |
< |
candidate.eta = 1.; |
152 |
> |
candidate.eta = bestKey.etaValue(); |
153 |
|
candidate.phi = bestKey.phiValue(); |
154 |
|
candidate.q = bestMatching.nMatchedTot(); |
155 |
|
candidate.type = L1Obj::OTF; |
168 |
|
static ENTRY entry; |
169 |
|
tree->SetBranchAddress("entry",&entry); |
170 |
|
Int_t nentries = (Int_t) tree->GetEntries(); |
171 |
< |
for (Int_t i=0; i<nentries; i++) { |
171 |
> |
for (Int_t i=0; i<nentries; ++i) { |
172 |
|
tree->GetEntry(i); |
173 |
|
GoldenPattern::Key key; |
174 |
|
key.theDet = entry.key_det; |
183 |
|
patternInpFile.Close(); |
184 |
|
} |
185 |
|
|
186 |
< |
void PatternManager::endJob() |
190 |
< |
{ |
191 |
< |
for (std::map< GoldenPattern::Key, GoldenPattern>::iterator igps = theGPs.begin(); igps != theGPs.end(); igps++) { |
192 |
< |
GoldenPattern & gp = igps->second; |
193 |
< |
gp.purge(); |
194 |
< |
} |
186 |
> |
void PatternManager::endJob(){ |
187 |
|
|
188 |
|
if ( !theConfig.exists("patternOutFile") ) return; |
189 |
|
std::string patternOutFileName = theConfig.getParameter<std::string>("patternOutFile"); |
190 |
|
TFile patternOutFile( patternOutFileName.c_str(),"RECREATE"); |
191 |
|
|
192 |
+ |
for (std::map< GoldenPattern::Key, GoldenPattern>::iterator igps = theGPs.begin(); igps != theGPs.end(); ++igps) { |
193 |
+ |
GoldenPattern & gp = igps->second; |
194 |
+ |
gp.purge(); |
195 |
+ |
} |
196 |
+ |
|
197 |
|
static ENTRY entry; |
198 |
|
TTree *tree = new TTree("FlatPatterns","FlatPatterns"); |
199 |
|
tree->Branch("entry",&entry,"key_det/i:key_pt/i:key_phi/i:key_ch/I:pat_Case/i:patDet/i:posOrBend/I:freq/i"); |
200 |
|
|
201 |
< |
for (std::map< GoldenPattern::Key, GoldenPattern>::const_iterator igps = theGPs.begin(); igps != theGPs.end(); igps++) { |
201 |
> |
for (std::map< GoldenPattern::Key, GoldenPattern>::const_iterator igps = theGPs.begin(); igps != theGPs.end(); ++igps) { |
202 |
|
const GoldenPattern & gp = igps->second; |
203 |
|
entry.key_det = gp.theKey.theDet; |
204 |
|
entry.key_pt = gp.theKey.thePtCode; |
205 |
|
entry.key_phi = gp.theKey.thePhiCode; |
206 |
|
entry.key_ch = gp.theKey.theCharge; |
207 |
< |
for (unsigned int iCase =1; iCase <=5; ++iCase) { |
208 |
< |
entry.pat_Case = iCase; |
209 |
< |
const GoldenPattern::DetFreq * detFreq = 0; |
210 |
< |
if (iCase==GoldenPattern::POSRPC) detFreq = &gp.posRpc; |
214 |
< |
if (iCase==GoldenPattern::POSCSC) detFreq = &gp.posCsc; |
215 |
< |
if (iCase==GoldenPattern::BENCSC) detFreq = &gp.bendingCsc; |
216 |
< |
if (iCase==GoldenPattern::POSDT ) detFreq = &gp.posDt; |
217 |
< |
if (iCase==GoldenPattern::BENDT ) detFreq = &gp.bendingDt; |
218 |
< |
for (GoldenPattern::DetFreq::const_iterator idf = detFreq->begin(); idf != detFreq->end(); idf++) { |
207 |
> |
|
208 |
> |
for (auto it=gp.PattCore.cbegin();it!=gp.PattCore.cend();++it){ |
209 |
> |
entry.pat_Case = it->first; |
210 |
> |
for (GoldenPattern::DetFreq::const_iterator idf = it->second.cbegin(); idf !=it->second.cend(); ++idf) { |
211 |
|
entry.patDet = idf->first; |
212 |
< |
for (GoldenPattern::MFreq::const_iterator imf = idf->second.begin(); imf != idf->second.end(); imf++) { |
212 |
> |
for (GoldenPattern::MFreq::const_iterator imf = idf->second.cbegin(); imf != idf->second.cend(); ++imf) { |
213 |
|
entry.posOrBend = imf->first; |
214 |
|
entry.freq = imf->second; |
215 |
|
tree->Fill(); |