16 |
|
#include "UserCode/L1RpcTriggerAnalysis/interface/BestMuonFinder.h" |
17 |
|
#include "UserCode/L1RpcTriggerAnalysis/interface/DetHitCompatibleCollector.h" |
18 |
|
#include "UserCode/L1RpcTriggerAnalysis/interface/L1ObjMaker.h" |
19 |
– |
#include "UserCode/L1RpcTriggerAnalysis/interface/L1ObjMakerRpcEmu.h" |
19 |
|
#include "UserCode/L1RpcTriggerAnalysis/interface/TrackToL1ObjMatcher.h" |
20 |
|
#include "DataFormats/RPCDigi/interface/RPCRawSynchro.h" |
21 |
|
#include "UserCode/L1RpcTriggerAnalysis/interface/ConverterRPCRawSynchroSynchroCountsObj.h" |
26 |
|
|
27 |
|
template <class T> T sqr( T t) {return t*t;} |
28 |
|
|
30 |
– |
|
29 |
|
L1RpcTreeMaker::L1RpcTreeMaker(const edm::ParameterSet& cfg) |
30 |
|
: theConfig(cfg), theTree(0), event(0), muon(0), track(0), |
31 |
|
bitsL1(0), bitsHLT(0), |
32 |
|
counts(0), |
33 |
< |
l1RpcColl(0) , l1OtherColl(0), l1RpcCollEmu(0), l1GmtColl(0), |
33 |
> |
l1ObjColl(0), |
34 |
|
theCounter(0), |
35 |
|
theBestMuonFinder(cfg.getParameter<edm::ParameterSet>("bestMuonFinder")), |
36 |
|
theDetHitCollector(cfg.getParameter<edm::ParameterSet>("detHitCollector")), |
37 |
|
theSynchroGrabber(cfg.getParameter<edm::ParameterSet>("linkSynchroGrabber")), |
38 |
+ |
theL1ObjMaker(cfg.getParameter<edm::ParameterSet>("l1ObjMaker")), |
39 |
|
theMenuInspector(edm::ParameterSet()) |
40 |
|
{ } |
41 |
|
|
63 |
|
theTree->Branch("detsHitsCompatibleWithMuon",&detsHitsCompatibleWithMuon); |
64 |
|
theTree->Branch("detsSIMU",&detsSIMU); |
65 |
|
|
66 |
< |
theTree->Branch("l1RpcColl","L1ObjColl",&l1RpcColl,32000,99); |
68 |
< |
theTree->Branch("l1RpcCollEmu","L1ObjColl",&l1RpcCollEmu,32000,99); |
69 |
< |
theTree->Branch("l1OtherColl","L1ObjColl",&l1OtherColl,32000,99); |
70 |
< |
theTree->Branch("l1GmtColl","L1ObjColl",&l1GmtColl,32000,99); |
66 |
> |
theTree->Branch("l1ObjColl","L1ObjColl",&l1ObjColl,32000,99); |
67 |
|
|
68 |
|
theHelper.SetOwner(); |
69 |
|
theBestMuonFinder.initHistos(theHelper); |
89 |
|
|
90 |
|
void L1RpcTreeMaker::analyze(const edm::Event &ev, const edm::EventSetup &es) |
91 |
|
{ |
96 |
– |
|
97 |
– |
|
92 |
|
// |
93 |
|
// check reference muon |
94 |
|
// |
95 |
|
const reco::Muon * theMuon = theBestMuonFinder.result(ev,es); |
96 |
< |
if (!theMuon || !theBestMuonFinder.isUnique(ev,es) ) return; |
96 |
> |
if (theConfig.getParameter<bool>("onlyBestMuEvents") && (!theMuon || !theBestMuonFinder.isUnique(ev,es)) ) return; |
97 |
|
theCounter++; |
98 |
|
|
99 |
|
// |
122 |
|
detsHitsCompatibleWithMuon = std::vector<DetCluDigiObj>(); |
123 |
|
detsSIMU = std::vector<uint32_t>(); |
124 |
|
|
125 |
< |
l1RpcColl = new L1ObjColl; |
132 |
< |
l1OtherColl = new L1ObjColl; |
133 |
< |
l1RpcCollEmu = new L1ObjColl; |
134 |
< |
l1GmtColl = new L1ObjColl; |
125 |
> |
l1ObjColl = new L1ObjColl; |
126 |
|
|
127 |
|
// |
128 |
|
// fill muon info |
129 |
|
// |
130 |
< |
muon->setKine(theMuon->track()->pt(), theMuon->track()->eta(), theMuon->track()->phi(), theMuon->track()->charge()); |
131 |
< |
muon->setBits(theMuon->isGlobalMuon(), theMuon->isTrackerMuon(), theMuon->isStandAloneMuon(), theMuon->isCaloMuon(), theMuon->isMatchesValid()); |
132 |
< |
muon->nMatchedStations = theMuon->numberOfMatchedStations(); |
133 |
< |
if (theMuon->isGlobalMuon()) { |
134 |
< |
const reco::HitPattern& hp = (theMuon->combinedMuon())->hitPattern(); |
135 |
< |
muon->nRPCHits = hp.numberOfValidMuonRPCHits(); |
136 |
< |
muon->nDTHits = hp.numberOfValidMuonDTHits(); |
137 |
< |
muon->nCSCHits = hp.numberOfValidMuonCSCHits(); |
138 |
< |
} else muon->nRPCHits = muon->nDTHits = muon->nCSCHits = 0; |
139 |
< |
muon->nTrackerHits = theMuon->isTrackerMuon() ? (theMuon->innerTrack())->hitPattern().numberOfValidTrackerHits() : 0; |
130 |
> |
if (theMuon) { |
131 |
> |
muon->setKine(theMuon->track()->pt(), theMuon->track()->eta(), theMuon->track()->phi(), theMuon->track()->charge()); |
132 |
> |
muon->setBits(theMuon->isGlobalMuon(), theMuon->isTrackerMuon(), theMuon->isStandAloneMuon(), theMuon->isCaloMuon(), theMuon->isMatchesValid()); |
133 |
> |
muon->nMatchedStations = theMuon->numberOfMatchedStations(); |
134 |
> |
if (theMuon->isGlobalMuon()) { |
135 |
> |
const reco::HitPattern& hp = (theMuon->combinedMuon())->hitPattern(); |
136 |
> |
muon->nRPCHits = hp.numberOfValidMuonRPCHits(); |
137 |
> |
muon->nDTHits = hp.numberOfValidMuonDTHits(); |
138 |
> |
muon->nCSCHits = hp.numberOfValidMuonCSCHits(); |
139 |
> |
} else muon->nRPCHits = muon->nDTHits = muon->nCSCHits = 0; |
140 |
> |
muon->nTrackerHits = theMuon->isTrackerMuon() ? (theMuon->innerTrack())->hitPattern().numberOfValidTrackerHits() : 0; |
141 |
> |
} |
142 |
|
|
143 |
|
// |
144 |
|
// fill algoBits info |
156 |
|
// |
157 |
|
// hits and detectors compatible with muon track |
158 |
|
// |
159 |
< |
if ( muon->pt() > 10.) { |
167 |
< |
/* |
168 |
< |
std::vector<DetHitCompatibleCollector::DetCluDigi> dhcm = theDetHitCollector.compatibleHits( theMuon, ev, es); |
169 |
< |
detsHitsCompatibleWithMuon.clear(); |
170 |
< |
for (std::vector<DetHitCompatibleCollector::DetCluDigi>::const_iterator it= dhcm.begin(); it < dhcm.end(); ++it) { |
171 |
< |
DetCluDigiObj obj; |
172 |
< |
obj.det = (*it).first; |
173 |
< |
obj.clusterSize = (*it).second.first; |
174 |
< |
obj.nDigis = (*it).second.second; |
175 |
< |
detsHitsCompatibleWithMuon.push_back(obj); |
176 |
< |
} |
177 |
< |
*/ |
159 |
> |
if (theMuon && muon->pt() > 10.) { |
160 |
|
detsHitsCompatibleWithMuon = theDetHitCollector.compatibleHits( theMuon, ev, es); |
161 |
|
detsCrossedByMuon = theDetHitCollector.compatibleDets( theMuon, ev, es, false); |
162 |
|
detsCrossedByMuonDeepInside = theDetHitCollector.compatibleDets( theMuon, ev, es, true); |
163 |
|
if (theConfig.getParameter<bool>("checkDestSIMU")) detsSIMU = theDetHitCollector.compatibleSIMU( theMuon, ev, es); |
182 |
– |
// for (uint32_t i=0; i< nDigisCompDets.size(); i++) { |
183 |
– |
// if (clSizeCompDets[i] > nDigisCompDets[i]) std::cout <<" PROBLEM, event: "<<theCounter<<" cl:"<<clSizeCompDets[i]<<" nDigis:"<<nDigisCompDets[i]<<std::endl; |
184 |
– |
// } |
164 |
|
} |
165 |
|
|
166 |
|
|
167 |
|
// |
168 |
|
// fill LinkSynchroAnalysis data |
169 |
|
// |
170 |
< |
theSynchroGrabber.setMuon(theMuon); |
171 |
< |
RPCRawSynchro::ProdItem rawCounts = theSynchroGrabber.counts(ev,es); |
172 |
< |
counts = ConverterRPCRawSynchroSynchroCountsObj::toSynchroObj(rawCounts); |
173 |
< |
|
195 |
< |
|
196 |
< |
// |
197 |
< |
// fill L1 RPCemu |
198 |
< |
// |
199 |
< |
if (theConfig.exists("l1RpcEmu") ) { |
200 |
< |
TrackToL1ObjMatcher matcher(theConfig.getParameter<edm::ParameterSet>("matcherPSet")); |
201 |
< |
L1ObjMakerRpcEmu l1RpcsFromEmu( theConfig.getParameter<edm::InputTag>("l1RpcEmu"), ev); |
202 |
< |
std::vector<L1Obj> l1RpcsEmu = l1RpcsFromEmu(); |
203 |
< |
std::vector<bool> l1RpcsEmuMatching(l1RpcsEmu.size(), false); |
204 |
< |
for(unsigned int i=0; i< l1RpcsEmu.size(); ++i) if (matcher(l1RpcsEmu[i].eta, l1RpcsEmu[i].phi, theMuon, ev,es)) l1RpcsEmuMatching[i]=true; |
205 |
< |
l1RpcCollEmu->set(l1RpcsEmu); |
206 |
< |
l1RpcCollEmu->set(l1RpcsEmuMatching); |
170 |
> |
if (theMuon) { |
171 |
> |
theSynchroGrabber.setMuon(theMuon); |
172 |
> |
RPCRawSynchro::ProdItem rawCounts = theSynchroGrabber.counts(ev,es); |
173 |
> |
counts = ConverterRPCRawSynchroSynchroCountsObj::toSynchroObj(rawCounts); |
174 |
|
} |
175 |
+ |
|
176 |
|
|
177 |
|
// |
178 |
< |
// fill L1 objects (Rpc,Oth) |
178 |
> |
// fill L1 info |
179 |
|
// |
180 |
< |
L1ObjMaker l1( theConfig.getParameter<edm::InputTag>("l1MuReadout"), ev); |
180 |
> |
std::vector<L1Obj> l1Obj = theL1ObjMaker(ev); |
181 |
> |
l1ObjColl->set( l1Obj); |
182 |
> |
std::vector<bool> matching(l1Obj.size(), false); |
183 |
> |
std::vector<double> deltaR(l1Obj.size(), 0.); |
184 |
|
TrackToL1ObjMatcher matcher(theConfig.getParameter<edm::ParameterSet>("matcherPSet")); |
185 |
< |
std::vector<L1Obj> l1Rpcs = l1(L1Obj::RPCB,L1Obj::RPCF); |
186 |
< |
std::vector<L1Obj> l1Others = l1(L1Obj::DT,L1Obj::CSC); |
187 |
< |
std::vector<L1Obj> l1Gmts = l1(L1Obj::GMT); |
188 |
< |
std::vector<bool> l1RpcsMatching(l1Rpcs.size(), false); |
189 |
< |
std::vector<bool> l1OthersMatching(l1Others.size(), false); |
190 |
< |
std::vector<bool> l1GmtsMatching(l1Gmts.size(), false); |
191 |
< |
for(unsigned int i=0; i< l1Rpcs.size(); ++i) if (matcher(l1Rpcs[i].eta, l1Rpcs[i].phi, theMuon, ev,es)) l1RpcsMatching[i]=true; |
192 |
< |
for(unsigned int i=0; i< l1Others.size(); ++i) if (matcher(l1Others[i].eta, l1Others[i].phi, theMuon, ev,es)) l1OthersMatching[i]=true; |
193 |
< |
for(unsigned int i=0; i< l1Gmts.size(); ++i) if (matcher(l1Gmts[i].eta, l1Gmts[i].phi, theMuon, ev,es)) l1GmtsMatching[i]=true; |
194 |
< |
l1RpcColl->set(l1Rpcs); |
195 |
< |
l1RpcColl->set(l1RpcsMatching); |
225 |
< |
l1OtherColl->set(l1Others); |
226 |
< |
l1OtherColl->set(l1OthersMatching); |
227 |
< |
l1GmtColl->set(l1Gmts); |
228 |
< |
l1GmtColl->set(l1GmtsMatching); |
229 |
< |
|
230 |
< |
|
231 |
< |
// std::cout <<"RPCColl:"<<std::endl; l1RpcColl->print(); |
232 |
< |
// std::cout <<"RPCCollEmu:"<<std::endl; l1RpcCollEmu->print(); |
185 |
> |
if (theMuon){ |
186 |
> |
for(unsigned int i=0; i< l1Obj.size(); ++i) { |
187 |
> |
if (matcher(l1Obj[i].eta, l1Obj[i].phi, theMuon, ev,es)) matching[i]=true; |
188 |
> |
TrackToL1ObjMatcher::LastResult result = matcher.lastResult(); |
189 |
> |
deltaR[i] = sqrt( sqr(result.deltaEta) + sqr(result.deltaPhi) ); |
190 |
> |
} |
191 |
> |
} |
192 |
> |
l1ObjColl->set( matching ); |
193 |
> |
l1ObjColl->set( deltaR ); |
194 |
> |
std::cout <<"----------"<<std::endl; |
195 |
> |
std::cout <<*l1ObjColl << std::endl; |
196 |
|
|
197 |
|
// |
198 |
|
// fill ntuple + cleanup |
204 |
|
delete track; track = 0; |
205 |
|
delete bitsL1; bitsL1= 0; |
206 |
|
delete bitsHLT; bitsHLT= 0; |
207 |
< |
delete l1RpcColl; l1RpcColl = 0; |
245 |
< |
delete l1OtherColl; l1OtherColl = 0; |
246 |
< |
delete l1RpcCollEmu; l1RpcCollEmu = 0; |
247 |
< |
delete l1GmtColl; l1GmtColl = 0; |
207 |
> |
delete l1ObjColl; l1ObjColl = 0; |
208 |
|
} |
209 |
|
|