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" |
24 |
|
#include "TFile.h" |
25 |
|
#include "TTree.h" |
26 |
|
|
27 |
< |
template <class T> T sqr( T t) {return t*t;} |
27 |
> |
//tmp |
28 |
> |
//#include "Geometry/CommonDetUnit/interface/GeomDet.h" |
29 |
> |
//#include "DataFormats/MuonDetId/interface/RPCDetId.h" |
30 |
> |
//#include "DataFormats/RPCRecHit/interface/RPCRecHitCollection.h" |
31 |
> |
//#include "DataFormats/DetId/interface/DetIdCollection.h" |
32 |
> |
|
33 |
|
|
34 |
+ |
template <class T> T sqr( T t) {return t*t;} |
35 |
|
|
36 |
|
L1RpcTreeMaker::L1RpcTreeMaker(const edm::ParameterSet& cfg) |
37 |
|
: theConfig(cfg), theTree(0), event(0), muon(0), track(0), |
38 |
|
bitsL1(0), bitsHLT(0), |
39 |
|
counts(0), |
40 |
< |
l1RpcColl(0) , l1OtherColl(0), l1RpcCollEmu(0), |
40 |
> |
l1ObjColl(0), |
41 |
|
theCounter(0), |
42 |
|
theBestMuonFinder(cfg.getParameter<edm::ParameterSet>("bestMuonFinder")), |
43 |
|
theDetHitCollector(cfg.getParameter<edm::ParameterSet>("detHitCollector")), |
44 |
< |
theSynchroGrabber(cfg.getParameter<edm::ParameterSet>("linkSynchroGrabber")) |
44 |
> |
theSynchroGrabber(cfg.getParameter<edm::ParameterSet>("linkSynchroGrabber")), |
45 |
> |
theL1ObjMaker(cfg.getParameter<edm::ParameterSet>("l1ObjMaker")), |
46 |
> |
theMenuInspector(edm::ParameterSet()) |
47 |
|
{ } |
48 |
|
|
49 |
< |
void L1RpcTreeMaker::beginRun( const edm::Run &ru, const edm::EventSetup &es) |
49 |
> |
void L1RpcTreeMaker::beginRun(const edm::Run &ru, const edm::EventSetup &es) |
50 |
|
{ |
51 |
+ |
std::cout <<" L1RpcTreeMaker::beginRun CALLED" << std::endl; |
52 |
+ |
theMenuInspector.checkRun(ru,es); |
53 |
|
} |
54 |
|
|
55 |
|
void L1RpcTreeMaker::beginJob() |
69 |
|
theTree->Branch("detsCrossedByMuonDeepInside",&detsCrossedByMuonDeepInside); |
70 |
|
theTree->Branch("detsHitsCompatibleWithMuon",&detsHitsCompatibleWithMuon); |
71 |
|
theTree->Branch("detsSIMU",&detsSIMU); |
63 |
– |
theTree->Branch("nDigisCompDets",&nDigisCompDets); |
64 |
– |
theTree->Branch("clSizeCompDets",&clSizeCompDets); |
72 |
|
|
73 |
< |
theTree->Branch("l1RpcColl","L1ObjColl",&l1RpcColl,32000,99); |
67 |
< |
theTree->Branch("l1RpcCollEmu","L1ObjColl",&l1RpcCollEmu,32000,99); |
68 |
< |
theTree->Branch("l1OtherColl","L1ObjColl",&l1OtherColl,32000,99); |
73 |
> |
theTree->Branch("l1ObjColl","L1ObjColl",&l1ObjColl,32000,99); |
74 |
|
|
75 |
|
theHelper.SetOwner(); |
76 |
|
theBestMuonFinder.initHistos(theHelper); |
96 |
|
|
97 |
|
void L1RpcTreeMaker::analyze(const edm::Event &ev, const edm::EventSetup &es) |
98 |
|
{ |
94 |
– |
|
95 |
– |
|
99 |
|
// |
100 |
|
// check reference muon |
101 |
|
// |
102 |
|
const reco::Muon * theMuon = theBestMuonFinder.result(ev,es); |
103 |
< |
if (!theMuon || !theBestMuonFinder.isUnique(ev,es) ) return; |
103 |
> |
if (theConfig.getParameter<bool>("onlyBestMuEvents") && (!theMuon) ) return; |
104 |
|
theCounter++; |
105 |
|
|
106 |
|
// |
123 |
|
bitsL1 = new TriggerMenuResultObj(); |
124 |
|
bitsHLT = new TriggerMenuResultObj(); |
125 |
|
|
123 |
– |
// counts = new SynchroCountsObjVect; |
126 |
|
counts = std::vector<SynchroCountsObj>(); |
127 |
|
detsCrossedByMuon = std::vector<uint32_t>(); |
128 |
|
detsCrossedByMuonDeepInside = std::vector<uint32_t>(); |
129 |
< |
detsHitsCompatibleWithMuon = std::vector<uint32_t>(); |
129 |
> |
detsHitsCompatibleWithMuon = std::vector<DetCluDigiObj>(); |
130 |
|
detsSIMU = std::vector<uint32_t>(); |
131 |
< |
nDigisCompDets = std::vector<uint32_t>(); |
132 |
< |
clSizeCompDets = std::vector<uint32_t>(); |
131 |
< |
l1RpcColl = new L1ObjColl; |
132 |
< |
l1OtherColl = new L1ObjColl; |
133 |
< |
l1RpcCollEmu = new L1ObjColl; |
131 |
> |
|
132 |
> |
l1ObjColl = new L1ObjColl; |
133 |
|
|
134 |
|
// |
135 |
|
// fill muon info |
136 |
|
// |
137 |
< |
muon->setKine(theMuon->track()->pt(), theMuon->track()->eta(), theMuon->track()->phi(), theMuon->track()->charge()); |
138 |
< |
muon->setBits(theMuon->isGlobalMuon(), theMuon->isTrackerMuon(), theMuon->isStandAloneMuon(), theMuon->isCaloMuon(), theMuon->isMatchesValid()); |
139 |
< |
muon->nMatchedStations = theMuon->numberOfMatchedStations(); |
140 |
< |
if (theMuon->isGlobalMuon()) { |
141 |
< |
const reco::HitPattern& hp = (theMuon->combinedMuon())->hitPattern(); |
142 |
< |
muon->nRPCHits = hp.numberOfValidMuonRPCHits(); |
143 |
< |
muon->nDTHits = hp.numberOfValidMuonDTHits(); |
144 |
< |
muon->nCSCHits = hp.numberOfValidMuonCSCHits(); |
145 |
< |
} else muon->nRPCHits = muon->nDTHits = muon->nCSCHits = 0; |
146 |
< |
muon->nTrackerHits = theMuon->isTrackerMuon() ? (theMuon->innerTrack())->hitPattern().numberOfValidTrackerHits() : 0; |
137 |
> |
muon->isUnique = theBestMuonFinder.isUnique(ev,es); |
138 |
> |
muon->nAllMuons = theBestMuonFinder.numberOfAllMuons(ev,es); |
139 |
> |
muon->nRPCHits = theBestMuonFinder.numberOfValidMuonRPCHits(); |
140 |
> |
muon->nDTHits = theBestMuonFinder.numberOfValidMuonDTHits(); |
141 |
> |
muon->nCSCHits = theBestMuonFinder.numberOfValidMuonCSCHits(); |
142 |
> |
muon->nTrackerHits = theBestMuonFinder.numberOfValidTrackerHits(); |
143 |
> |
if (theMuon) { |
144 |
> |
muon->setKine(theMuon->bestTrack()->pt(), theMuon->bestTrack()->eta(), theMuon->bestTrack()->phi(), theMuon->bestTrack()->charge()); |
145 |
> |
muon->setBits(theMuon->isGlobalMuon(), theMuon->isTrackerMuon(), theMuon->isStandAloneMuon(), theMuon->isCaloMuon(), theMuon->isMatchesValid()); |
146 |
> |
muon->nMatchedStations = theMuon->numberOfMatchedStations(); |
147 |
> |
} |
148 |
|
|
149 |
+ |
// |
150 |
+ |
// fill algoBits info |
151 |
+ |
// |
152 |
+ |
static edm::RunNumber_t lastRun = 0; |
153 |
+ |
if (ev.run() != lastRun) { |
154 |
+ |
lastRun = ev.run(); |
155 |
+ |
bitsL1->names = theMenuInspector.namesAlgoL1(); |
156 |
+ |
bitsHLT->names = theMenuInspector.namesAlgoHLT(); |
157 |
+ |
} |
158 |
+ |
bitsL1->firedAlgos = theMenuInspector.firedAlgosL1(ev,es); |
159 |
+ |
bitsHLT->firedAlgos = theMenuInspector.firedAlgosHLT(ev,es); |
160 |
+ |
|
161 |
+ |
|
162 |
+ |
/* tmp |
163 |
+ |
edm::Handle<RPCRecHitCollection> recHits; |
164 |
+ |
ev.getByLabel("rpcRecHits", recHits); |
165 |
+ |
typedef RPCRecHitCollection::const_iterator IH; |
166 |
+ |
std::cout <<"Event: " << *event << std::endl; |
167 |
+ |
for (IH ih=recHits->begin(); ih != recHits->end(); ++ih) { |
168 |
+ |
std::cout <<"Det: "<< ih->rpcId()<<"is valid: "<< ih->isValid()<< "BX= "<<ih->BunchX() << std::endl; |
169 |
+ |
} |
170 |
+ |
*/ |
171 |
|
|
172 |
|
// |
173 |
|
// hits and detectors compatible with muon track |
174 |
|
// |
175 |
< |
if ( muon->pt() > 10.) { |
176 |
< |
detsHitsCompatibleWithMuon = theDetHitCollector.compatibleHits( theMuon, ev, es); |
175 |
> |
if (theMuon && muon->pt() > 10. && theMuon->isGlobalMuon()) { |
176 |
> |
detsHitsCompatibleWithMuon = theDetHitCollector.compatibleHits( theMuon, ev, es); |
177 |
|
detsCrossedByMuon = theDetHitCollector.compatibleDets( theMuon, ev, es, false); |
178 |
|
detsCrossedByMuonDeepInside = theDetHitCollector.compatibleDets( theMuon, ev, es, true); |
179 |
|
if (theConfig.getParameter<bool>("checkDestSIMU")) detsSIMU = theDetHitCollector.compatibleSIMU( theMuon, ev, es); |
158 |
– |
nDigisCompDets = theDetHitCollector.nDigisCompDets(detsHitsCompatibleWithMuon, ev, es); |
159 |
– |
clSizeCompDets = theDetHitCollector.clSizeCompDets(detsHitsCompatibleWithMuon, ev, es); |
160 |
– |
|
161 |
– |
for (uint32_t i=0; i< nDigisCompDets.size(); i++) { |
162 |
– |
if (clSizeCompDets[i] > nDigisCompDets[i]) std::cout <<" PROBLEM, event: "<<theCounter<<" cl:"<<clSizeCompDets[i]<<" nDigis:"<<nDigisCompDets[i]<<std::endl; |
163 |
– |
} |
180 |
|
} |
181 |
|
|
182 |
|
|
183 |
|
// |
184 |
|
// fill LinkSynchroAnalysis data |
185 |
|
// |
186 |
< |
theSynchroGrabber.setMuon(theMuon); |
187 |
< |
RPCRawSynchro::ProdItem rawCounts = theSynchroGrabber.counts(ev,es); |
188 |
< |
counts = ConverterRPCRawSynchroSynchroCountsObj::toSynchroObj(rawCounts); |
189 |
< |
|
174 |
< |
|
175 |
< |
// |
176 |
< |
// fill L1 RPCemu |
177 |
< |
// |
178 |
< |
if (theConfig.exists("l1RpcEmu") ) { |
179 |
< |
TrackToL1ObjMatcher matcher(theConfig.getParameter<edm::ParameterSet>("matcherPSet")); |
180 |
< |
L1ObjMakerRpcEmu l1RpcsFromEmu( theConfig.getParameter<edm::InputTag>("l1RpcEmu"), ev); |
181 |
< |
std::vector<L1Obj> l1RpcsEmu = l1RpcsFromEmu(); |
182 |
< |
std::vector<bool> l1RpcsEmuMatching(l1RpcsEmu.size(), false); |
183 |
< |
for(unsigned int i=0; i< l1RpcsEmu.size(); ++i) if (matcher(l1RpcsEmu[i].eta, l1RpcsEmu[i].phi, theMuon, ev,es)) l1RpcsEmuMatching[i]=true; |
184 |
< |
l1RpcCollEmu->set(l1RpcsEmu); |
185 |
< |
l1RpcCollEmu->set(l1RpcsEmuMatching); |
186 |
> |
if (theMuon && theMuon->isGlobalMuon()) { |
187 |
> |
theSynchroGrabber.setMuon(theMuon); |
188 |
> |
RPCRawSynchro::ProdItem rawCounts = theSynchroGrabber.counts(ev,es); |
189 |
> |
counts = ConverterRPCRawSynchroSynchroCountsObj::toSynchroObj(rawCounts); |
190 |
|
} |
191 |
+ |
|
192 |
|
|
193 |
|
// |
194 |
< |
// fill L1 objects (Rpc,Oth) |
194 |
> |
// fill L1 info |
195 |
|
// |
196 |
< |
L1ObjMaker l1( theConfig.getParameter<edm::InputTag>("l1MuReadout"), ev); |
196 |
> |
std::vector<L1Obj> l1Obj = theL1ObjMaker(ev); |
197 |
> |
l1ObjColl->set( l1Obj); |
198 |
> |
std::vector<bool> matching(l1Obj.size(), false); |
199 |
> |
std::vector<double> deltaR(l1Obj.size(), 999.); |
200 |
|
TrackToL1ObjMatcher matcher(theConfig.getParameter<edm::ParameterSet>("matcherPSet")); |
201 |
< |
std::vector<L1Obj> l1Rpcs = l1(L1ObjMaker::RPCB,L1ObjMaker::RPCF); |
202 |
< |
std::vector<L1Obj> l1Others = l1(L1ObjMaker::DT,L1ObjMaker::CSC); |
203 |
< |
std::vector<bool> l1RpcsMatching(l1Rpcs.size(), false); |
204 |
< |
std::vector<bool> l1OthersMatching(l1Others.size(), false); |
205 |
< |
for(unsigned int i=0; i< l1Rpcs.size(); ++i) if (matcher(l1Rpcs[i].eta, l1Rpcs[i].phi, theMuon, ev,es)) l1RpcsMatching[i]=true; |
206 |
< |
for(unsigned int i=0; i< l1Others.size(); ++i) if (matcher(l1Others[i].eta, l1Others[i].phi, theMuon, ev,es)) l1OthersMatching[i]=true; |
207 |
< |
l1RpcColl->set(l1Rpcs); |
208 |
< |
l1RpcColl->set(l1RpcsMatching); |
209 |
< |
l1OtherColl->set(l1Others); |
210 |
< |
l1OtherColl->set(l1OthersMatching); |
211 |
< |
|
204 |
< |
// std::cout <<"RPCColl:"<<std::endl; l1RpcColl->print(); |
205 |
< |
// std::cout <<"RPCCollEmu:"<<std::endl; l1RpcCollEmu->print(); |
201 |
> |
if (theMuon && theMuon->isGlobalMuon()){ |
202 |
> |
for(unsigned int i=0; i< l1Obj.size(); ++i) { |
203 |
> |
if (matcher(l1Obj[i].eta, l1Obj[i].phi, theMuon, ev,es)) matching[i]=true; |
204 |
> |
TrackToL1ObjMatcher::LastResult result = matcher.lastResult(); |
205 |
> |
deltaR[i] = sqrt( sqr(result.deltaEta) + sqr(result.deltaPhi) ); |
206 |
> |
} |
207 |
> |
} |
208 |
> |
l1ObjColl->set( matching ); |
209 |
> |
l1ObjColl->set( deltaR ); |
210 |
> |
// std::cout <<"----------"<<std::endl; |
211 |
> |
// std::cout <<*l1ObjColl << std::endl; |
212 |
|
|
213 |
|
// |
214 |
|
// fill ntuple + cleanup |
220 |
|
delete track; track = 0; |
221 |
|
delete bitsL1; bitsL1= 0; |
222 |
|
delete bitsHLT; bitsHLT= 0; |
223 |
< |
delete l1RpcColl; l1RpcColl = 0; |
218 |
< |
delete l1OtherColl; l1OtherColl = 0; |
219 |
< |
delete l1RpcCollEmu; l1RpcCollEmu = 0; |
223 |
> |
delete l1ObjColl; l1ObjColl = 0; |
224 |
|
} |
225 |
|
|