1 |
konec |
1.1 |
#include "L1RpcTreeMaker.h"
|
2 |
|
|
#include <vector>
|
3 |
|
|
|
4 |
|
|
#include "FWCore/Framework/interface/Event.h"
|
5 |
|
|
#include "FWCore/Framework/interface/EventSetup.h"
|
6 |
|
|
#include "FWCore/Framework/interface/ESHandle.h"
|
7 |
|
|
#include "DataFormats/Common/interface/Handle.h"
|
8 |
|
|
|
9 |
|
|
#include "DataFormats/MuonReco/interface/Muon.h"
|
10 |
|
|
#include "DataFormats/MuonReco/interface/MuonFwd.h"
|
11 |
|
|
#include "DataFormats/MuonReco/interface/MuonSelectors.h"
|
12 |
|
|
#include "DataFormats/TrackReco/interface/TrackFwd.h"
|
13 |
|
|
#include "DataFormats/TrackReco/interface/Track.h"
|
14 |
|
|
|
15 |
|
|
|
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"
|
20 |
|
|
#include "UserCode/L1RpcTriggerAnalysis/interface/TrackToL1ObjMatcher.h"
|
21 |
|
|
#include "DataFormats/RPCDigi/interface/RPCRawSynchro.h"
|
22 |
|
|
#include "UserCode/L1RpcTriggerAnalysis/interface/ConverterRPCRawSynchroSynchroCountsObj.h"
|
23 |
konec |
1.4 |
#include "UserCode/L1RpcTriggerAnalysis/interface/TriggerMenuResultObj.h"
|
24 |
konec |
1.1 |
|
25 |
|
|
#include "TFile.h"
|
26 |
|
|
#include "TTree.h"
|
27 |
|
|
|
28 |
konec |
1.9 |
#include "DataFormats/L1GlobalMuonTrigger/interface/L1MuRegionalCand.h"
|
29 |
|
|
#include "DataFormats/L1GlobalMuonTrigger/interface/L1MuGMTCand.h"
|
30 |
|
|
#include "DataFormats/L1GlobalMuonTrigger/interface/L1MuGMTExtendedCand.h"
|
31 |
|
|
#include "DataFormats/L1GlobalMuonTrigger/interface/L1MuGMTReadoutCollection.h"
|
32 |
|
|
|
33 |
konec |
1.1 |
template <class T> T sqr( T t) {return t*t;}
|
34 |
|
|
|
35 |
|
|
|
36 |
|
|
L1RpcTreeMaker::L1RpcTreeMaker(const edm::ParameterSet& cfg)
|
37 |
konec |
1.4 |
: theConfig(cfg), theTree(0), event(0), muon(0), track(0),
|
38 |
|
|
bitsL1(0), bitsHLT(0),
|
39 |
|
|
counts(0),
|
40 |
konec |
1.6 |
l1RpcColl(0) , l1OtherColl(0), l1RpcCollEmu(0), l1GmtColl(0),
|
41 |
konec |
1.1 |
theCounter(0),
|
42 |
|
|
theBestMuonFinder(cfg.getParameter<edm::ParameterSet>("bestMuonFinder")),
|
43 |
|
|
theDetHitCollector(cfg.getParameter<edm::ParameterSet>("detHitCollector")),
|
44 |
konec |
1.5 |
theSynchroGrabber(cfg.getParameter<edm::ParameterSet>("linkSynchroGrabber")),
|
45 |
|
|
theMenuInspector(edm::ParameterSet())
|
46 |
konec |
1.1 |
{ }
|
47 |
|
|
|
48 |
konec |
1.5 |
void L1RpcTreeMaker::beginRun(const edm::Run &ru, const edm::EventSetup &es)
|
49 |
konec |
1.1 |
{
|
50 |
konec |
1.5 |
std::cout <<" L1RpcTreeMaker::beginRun CALLED" << std::endl;
|
51 |
|
|
theMenuInspector.checkRun(ru,es);
|
52 |
konec |
1.1 |
}
|
53 |
|
|
|
54 |
|
|
void L1RpcTreeMaker::beginJob()
|
55 |
|
|
{
|
56 |
|
|
theFile = new TFile(theConfig.getParameter<std::string>("treeFileName").c_str(),"RECREATE");
|
57 |
|
|
theTree = new TTree("tL1Rpc","L1RpcEfficciency");
|
58 |
|
|
|
59 |
|
|
theTree->Branch("event","EventObj",&event,32000,99);
|
60 |
|
|
theTree->Branch("muon","MuonObj",&muon,32000,99);
|
61 |
|
|
theTree->Branch("track", "TrackObj",&track,32000,99);
|
62 |
|
|
|
63 |
konec |
1.4 |
theTree->Branch("bitsL1" ,"TriggerMenuResultObj",&bitsL1 ,32000,99);
|
64 |
|
|
theTree->Branch("bitsHLT","TriggerMenuResultObj",&bitsHLT,32000,99);
|
65 |
|
|
|
66 |
konec |
1.1 |
theTree->Branch("counts",&counts);
|
67 |
|
|
theTree->Branch("detsCrossedByMuon",&detsCrossedByMuon);
|
68 |
|
|
theTree->Branch("detsCrossedByMuonDeepInside",&detsCrossedByMuonDeepInside);
|
69 |
|
|
theTree->Branch("detsHitsCompatibleWithMuon",&detsHitsCompatibleWithMuon);
|
70 |
|
|
theTree->Branch("detsSIMU",&detsSIMU);
|
71 |
|
|
|
72 |
|
|
theTree->Branch("l1RpcColl","L1ObjColl",&l1RpcColl,32000,99);
|
73 |
|
|
theTree->Branch("l1RpcCollEmu","L1ObjColl",&l1RpcCollEmu,32000,99);
|
74 |
|
|
theTree->Branch("l1OtherColl","L1ObjColl",&l1OtherColl,32000,99);
|
75 |
konec |
1.6 |
theTree->Branch("l1GmtColl","L1ObjColl",&l1GmtColl,32000,99);
|
76 |
konec |
1.1 |
|
77 |
|
|
theHelper.SetOwner();
|
78 |
|
|
theBestMuonFinder.initHistos(theHelper);
|
79 |
|
|
theDetHitCollector.initHistos(theHelper);
|
80 |
|
|
theSynchroGrabber.initHistos(theHelper);
|
81 |
|
|
}
|
82 |
|
|
|
83 |
|
|
void L1RpcTreeMaker::endJob()
|
84 |
|
|
{
|
85 |
|
|
theFile->Write();
|
86 |
|
|
delete theFile;
|
87 |
|
|
|
88 |
|
|
std::string helperFile = theConfig.getParameter<std::string>("histoFileName");
|
89 |
|
|
TFile f(helperFile.c_str(),"RECREATE");
|
90 |
|
|
theHelper.Write();
|
91 |
|
|
f.Close();
|
92 |
|
|
}
|
93 |
|
|
|
94 |
|
|
L1RpcTreeMaker::~L1RpcTreeMaker()
|
95 |
|
|
{
|
96 |
|
|
std::cout <<"L1RpcTreeMaker: Event counter is: "<<theCounter<<std::endl;
|
97 |
|
|
}
|
98 |
|
|
|
99 |
|
|
void L1RpcTreeMaker::analyze(const edm::Event &ev, const edm::EventSetup &es)
|
100 |
|
|
{
|
101 |
|
|
//
|
102 |
|
|
// check reference muon
|
103 |
|
|
//
|
104 |
|
|
const reco::Muon * theMuon = theBestMuonFinder.result(ev,es);
|
105 |
|
|
if (!theMuon || !theBestMuonFinder.isUnique(ev,es) ) return;
|
106 |
|
|
theCounter++;
|
107 |
|
|
|
108 |
|
|
//
|
109 |
|
|
// fill event information
|
110 |
|
|
//
|
111 |
|
|
event = new EventObj;
|
112 |
|
|
event->bx = ev.bunchCrossing();
|
113 |
|
|
event->orbit = ev.orbitNumber();
|
114 |
|
|
event->time = ev.time().value();
|
115 |
|
|
event->id = ev.id().event();
|
116 |
|
|
event->run = ev.run();
|
117 |
|
|
event->lumi = ev.luminosityBlock();
|
118 |
|
|
|
119 |
|
|
//
|
120 |
|
|
// create other objects structure
|
121 |
|
|
//
|
122 |
|
|
muon = new MuonObj();
|
123 |
|
|
track = new TrackObj();
|
124 |
konec |
1.4 |
|
125 |
|
|
bitsL1 = new TriggerMenuResultObj();
|
126 |
|
|
bitsHLT = new TriggerMenuResultObj();
|
127 |
|
|
|
128 |
konec |
1.1 |
counts = std::vector<SynchroCountsObj>();
|
129 |
|
|
detsCrossedByMuon = std::vector<uint32_t>();
|
130 |
|
|
detsCrossedByMuonDeepInside = std::vector<uint32_t>();
|
131 |
konec |
1.6 |
detsHitsCompatibleWithMuon = std::vector<DetCluDigiObj>();
|
132 |
konec |
1.1 |
detsSIMU = std::vector<uint32_t>();
|
133 |
konec |
1.6 |
|
134 |
konec |
1.1 |
l1RpcColl = new L1ObjColl;
|
135 |
|
|
l1OtherColl = new L1ObjColl;
|
136 |
|
|
l1RpcCollEmu = new L1ObjColl;
|
137 |
konec |
1.6 |
l1GmtColl = new L1ObjColl;
|
138 |
konec |
1.1 |
|
139 |
|
|
//
|
140 |
|
|
// fill muon info
|
141 |
|
|
//
|
142 |
|
|
muon->setKine(theMuon->track()->pt(), theMuon->track()->eta(), theMuon->track()->phi(), theMuon->track()->charge());
|
143 |
|
|
muon->setBits(theMuon->isGlobalMuon(), theMuon->isTrackerMuon(), theMuon->isStandAloneMuon(), theMuon->isCaloMuon(), theMuon->isMatchesValid());
|
144 |
|
|
muon->nMatchedStations = theMuon->numberOfMatchedStations();
|
145 |
|
|
if (theMuon->isGlobalMuon()) {
|
146 |
|
|
const reco::HitPattern& hp = (theMuon->combinedMuon())->hitPattern();
|
147 |
|
|
muon->nRPCHits = hp.numberOfValidMuonRPCHits();
|
148 |
|
|
muon->nDTHits = hp.numberOfValidMuonDTHits();
|
149 |
|
|
muon->nCSCHits = hp.numberOfValidMuonCSCHits();
|
150 |
|
|
} else muon->nRPCHits = muon->nDTHits = muon->nCSCHits = 0;
|
151 |
|
|
muon->nTrackerHits = theMuon->isTrackerMuon() ? (theMuon->innerTrack())->hitPattern().numberOfValidTrackerHits() : 0;
|
152 |
|
|
|
153 |
konec |
1.5 |
//
|
154 |
|
|
// fill algoBits info
|
155 |
|
|
//
|
156 |
|
|
static edm::RunNumber_t lastRun = 0;
|
157 |
|
|
if (ev.run() != lastRun) {
|
158 |
|
|
lastRun = ev.run();
|
159 |
|
|
bitsL1->names = theMenuInspector.namesAlgoL1();
|
160 |
|
|
bitsHLT->names = theMenuInspector.namesAlgoHLT();
|
161 |
|
|
}
|
162 |
|
|
bitsL1->firedAlgos = theMenuInspector.firedAlgosL1(ev,es);
|
163 |
|
|
bitsHLT->firedAlgos = theMenuInspector.firedAlgosHLT(ev,es);
|
164 |
|
|
|
165 |
konec |
1.1 |
|
166 |
|
|
//
|
167 |
|
|
// hits and detectors compatible with muon track
|
168 |
|
|
//
|
169 |
|
|
if ( muon->pt() > 10.) {
|
170 |
konec |
1.6 |
detsHitsCompatibleWithMuon = theDetHitCollector.compatibleHits( theMuon, ev, es);
|
171 |
konec |
1.1 |
detsCrossedByMuon = theDetHitCollector.compatibleDets( theMuon, ev, es, false);
|
172 |
|
|
detsCrossedByMuonDeepInside = theDetHitCollector.compatibleDets( theMuon, ev, es, true);
|
173 |
|
|
if (theConfig.getParameter<bool>("checkDestSIMU")) detsSIMU = theDetHitCollector.compatibleSIMU( theMuon, ev, es);
|
174 |
|
|
}
|
175 |
|
|
|
176 |
|
|
|
177 |
|
|
//
|
178 |
|
|
// fill LinkSynchroAnalysis data
|
179 |
|
|
//
|
180 |
|
|
theSynchroGrabber.setMuon(theMuon);
|
181 |
|
|
RPCRawSynchro::ProdItem rawCounts = theSynchroGrabber.counts(ev,es);
|
182 |
|
|
counts = ConverterRPCRawSynchroSynchroCountsObj::toSynchroObj(rawCounts);
|
183 |
|
|
|
184 |
|
|
|
185 |
|
|
//
|
186 |
|
|
// fill L1 RPCemu
|
187 |
|
|
//
|
188 |
konec |
1.7 |
if (theConfig.exists("l1RpcEmu")) {
|
189 |
konec |
1.1 |
TrackToL1ObjMatcher matcher(theConfig.getParameter<edm::ParameterSet>("matcherPSet"));
|
190 |
|
|
L1ObjMakerRpcEmu l1RpcsFromEmu( theConfig.getParameter<edm::InputTag>("l1RpcEmu"), ev);
|
191 |
|
|
std::vector<L1Obj> l1RpcsEmu = l1RpcsFromEmu();
|
192 |
|
|
std::vector<bool> l1RpcsEmuMatching(l1RpcsEmu.size(), false);
|
193 |
|
|
for(unsigned int i=0; i< l1RpcsEmu.size(); ++i) if (matcher(l1RpcsEmu[i].eta, l1RpcsEmu[i].phi, theMuon, ev,es)) l1RpcsEmuMatching[i]=true;
|
194 |
|
|
l1RpcCollEmu->set(l1RpcsEmu);
|
195 |
|
|
l1RpcCollEmu->set(l1RpcsEmuMatching);
|
196 |
|
|
}
|
197 |
|
|
|
198 |
|
|
//
|
199 |
|
|
// fill L1 objects (Rpc,Oth)
|
200 |
|
|
//
|
201 |
|
|
L1ObjMaker l1( theConfig.getParameter<edm::InputTag>("l1MuReadout"), ev);
|
202 |
|
|
TrackToL1ObjMatcher matcher(theConfig.getParameter<edm::ParameterSet>("matcherPSet"));
|
203 |
konec |
1.6 |
std::vector<L1Obj> l1Rpcs = l1(L1Obj::RPCB,L1Obj::RPCF);
|
204 |
|
|
std::vector<L1Obj> l1Others = l1(L1Obj::DT,L1Obj::CSC);
|
205 |
|
|
std::vector<L1Obj> l1Gmts = l1(L1Obj::GMT);
|
206 |
konec |
1.1 |
std::vector<bool> l1RpcsMatching(l1Rpcs.size(), false);
|
207 |
|
|
std::vector<bool> l1OthersMatching(l1Others.size(), false);
|
208 |
konec |
1.6 |
std::vector<bool> l1GmtsMatching(l1Gmts.size(), false);
|
209 |
konec |
1.1 |
for(unsigned int i=0; i< l1Rpcs.size(); ++i) if (matcher(l1Rpcs[i].eta, l1Rpcs[i].phi, theMuon, ev,es)) l1RpcsMatching[i]=true;
|
210 |
|
|
for(unsigned int i=0; i< l1Others.size(); ++i) if (matcher(l1Others[i].eta, l1Others[i].phi, theMuon, ev,es)) l1OthersMatching[i]=true;
|
211 |
konec |
1.6 |
for(unsigned int i=0; i< l1Gmts.size(); ++i) if (matcher(l1Gmts[i].eta, l1Gmts[i].phi, theMuon, ev,es)) l1GmtsMatching[i]=true;
|
212 |
konec |
1.1 |
l1RpcColl->set(l1Rpcs);
|
213 |
|
|
l1RpcColl->set(l1RpcsMatching);
|
214 |
|
|
l1OtherColl->set(l1Others);
|
215 |
|
|
l1OtherColl->set(l1OthersMatching);
|
216 |
konec |
1.6 |
l1GmtColl->set(l1Gmts);
|
217 |
|
|
l1GmtColl->set(l1GmtsMatching);
|
218 |
|
|
|
219 |
konec |
1.1 |
|
220 |
konec |
1.8 |
std::cout <<"----"<<std::endl;
|
221 |
|
|
std::cout <<"RPCColl: "<<std::endl; l1RpcColl->print();
|
222 |
|
|
std::cout <<"RPCCollEmu:"<<std::endl; l1RpcCollEmu->print();
|
223 |
|
|
std::cout <<"GmtColl: "<<std::endl; l1GmtColl->print();
|
224 |
|
|
std::cout <<"GmtCollEmu:"<<std::endl;
|
225 |
konec |
1.9 |
|
226 |
|
|
// edm::Handle<L1MuGMTReadoutCollection> pCollection;
|
227 |
|
|
// ev.getByLabel(l1MuReadout,pCollection);
|
228 |
|
|
// std::cout <<"IS COLLECTION VALID: "<< pCollection->isValid() << std::endl;
|
229 |
|
|
L1ObjMaker l1Bis( edm::InputTag("mkGmtDigis"), ev);
|
230 |
konec |
1.8 |
std::vector<L1Obj> l1GmtsEmu = l1Bis(L1Obj::GMT);
|
231 |
|
|
for (unsigned int i=0; i<l1GmtsEmu.size(); ++i) {
|
232 |
|
|
std::cout <<"("<<i<<")";l1GmtsEmu[i].print();
|
233 |
|
|
std::cout <<std::endl;
|
234 |
|
|
}
|
235 |
konec |
1.1 |
|
236 |
|
|
//
|
237 |
|
|
// fill ntuple + cleanup
|
238 |
|
|
//
|
239 |
|
|
//std::cout <<" THIS event written!" << std::endl;
|
240 |
|
|
theTree->Fill();
|
241 |
|
|
delete event; event = 0;
|
242 |
|
|
delete muon; muon = 0;
|
243 |
|
|
delete track; track = 0;
|
244 |
konec |
1.4 |
delete bitsL1; bitsL1= 0;
|
245 |
|
|
delete bitsHLT; bitsHLT= 0;
|
246 |
konec |
1.1 |
delete l1RpcColl; l1RpcColl = 0;
|
247 |
|
|
delete l1OtherColl; l1OtherColl = 0;
|
248 |
|
|
delete l1RpcCollEmu; l1RpcCollEmu = 0;
|
249 |
konec |
1.6 |
delete l1GmtColl; l1GmtColl = 0;
|
250 |
konec |
1.1 |
}
|
251 |
|
|
|